VFP diacritic removal - sql

I am having a problem with a code responsible for removing (replacing) diacritic in a file, using VPF 9.0.
I am using this command for uppercasing and removing the diacritic:
UPPER(CHRTRAN(ALLTRIM(XNAME),"áäÁÄčČďĎéÉíÍĺľĹĽňóôöőÓÔÖŐŕŔšŠťŤúüűÚÜŰýÝžŽ","AAAACCDDEEIILLLLNOOOOOOOORRSSTTUUUUUUYYZZ"))
The problem is that the first set of characters looks different upon saving. First line is how it should look like, the second is how it actually looks after saving:
"áäÁÄčČďĎéÉíÍĺľĹĽňóôöőÓÔÖŐŕŔšŠťŤúüűÚÜŰýÝžŽ"
"áäÁÄčEďIéÉíÍĺ_ĹĽňóôöoÓÔÖOŕAšŠťŤúüűÚÜUýÝžÄ"
It removes some of the diacritic marks and I can't make it save in the wanted format.
Would you be able to help me with this, please?

Can you please right click the file in project manager and check 'Code page'? By default it should be windows ANSI (1252) and work right.
Edit:
To do from command line.
MODIFY COMMAND myDiacratics.prg AS 1252
when the file comes up, make a change (any change so it would be forced to save) and save. It should save just as you want to.

Related

What is the meaning of the file names flanked by the '#' sign and how can I remove them?

When I do the 'ls' command in the terminal on my Raspberry Pi 2, I see different types of names of files, some like "#example.cpp#", as well as others like "homework1.cpp~".
What do these two file types mean, and how can I get rid of them? Simply using the 'rm' command doesn't seem to be working for me. Thanks!
Some applications will create a copy of a file and use special characters when creating the filename for the copy. For instance some text editors will make a copy of a file you are starting to edit by using the same name and adding a tilde character (~) to the end of the file. That way you will have a backup of the file that you are about to edit.
Another reason would be if an application is processing the file into a temporary file with the temporary file then being used for the next step. For example perhaps the C/C++ compiler is reading the file homework1.cpp with the C Preprocessor to generate the temporary file #homework1.cpp# which is then compiled by the compiler to generate the object code file.
I am not familiar with raspberry pi so am not sure as to what may be creating the filenames with the pound sign (#) on the front and back. Perhaps it is the C++ compiler. I am pretty sure the files with the tilde character on appended to the end of the file name is a back file from vi or vim containing a copy of the file at the time it was last opened with the text editor.
One thing that you could do is to look in those files to see what is there using a Linux command or a text editor. If you use a text editor I would copy the file to another folder as a back up and then look at it there.
Edit: Someone just posted and then deleted an answer which also mentioned about how to remove these files.
What I read was that the rm command is used however for some kinds of special characters you will need to use quotes around the name and you may also need to use an escape to escape certain special characters.
The command shell reads the command line you type in and makes changes to the text before passing it on to the command you type in. So if the filename has a space in it, say jj Johny then when you remove the file you have to specify rm "jj Johny" since spaces are used by the command processor to separate out arguments.
The other poster mentioned that you had to escape out the pound sign (#) using the back slash character in order to prevent it from being modified by the command processor.

Intellij - Reformat Code - Insert whitespace between // and the comment-text?

I am working with another human being on project from that the professor expects to have uniform code-style. We have written large separate junks of code on our own, in which one has written single line comments without a white-space between the single-line-comment-token and the other one has inserted a white-space. We are working with IntelliJ and have failed to find an option to enable the Reformat Code function, to insert a white-space.
TLDR:
Can you tell us how to convert comments from that to this in IntelliJ?
// This is a load bearing comment - don't dare to remove it
//This is a load bearing comment - don't dare to remove it!
You can do a global search and replace (ctrl-shift-r on windows with default keyboard layout, or Replace in Path under the Edit/Find menu).
Check the regular expression option and enter //(\S.*) as the text to find and // $1 as the replacement. Check the whole project option, and clear any file masks. You can single step through the replacements, or simply hit the All Files option.

Format TSQL onto one line

Our company uses an old app which reads TSQL from a .INI file. Due to how the app process the INI file the TSQL has to be all on one line. I use Poor Mans TSQL Formatter to get everything nice and tidy for things like SPs, but am wondering if there's something out there to do the reverse - take nicely formatted TSQL and shove it all onto one line (removing carriage returns , line breaks etc).
I'm working in SSMS but also use Notepad++, and will happily use some other editor if it has the functionality.
Using Notepad++ (Without any plugin)
After lot's of googling I found that there are no plugins like TextFX and PoorMansTSqlFormatter are available in x64 bit version of notepad++ even not needed.
Notepad++ --> Write Query --> Edit --> Blank Options --> Remove Unnecessary Blank and EOL.
That's it.
Using Notepad++
Select the statement that is over multiple lines then on the menu: TextFX>TextFX Edit>Unwrap Text
And for even greater ease you can assign it to a keyboard shortcut using the shortcut mapper (Settings>Shortcut Mapper)
You can use the minify comment to remove all the unnecessary space in the Poor Mans TSQL Formatter
[minify]
[/minify]
I like Martin's answer and that is probably the way to go. But I'll point out that you can just use string manipulation to turn carriage returns and line feeds into spaces. This is particularly easy in the later versions of SSMS that enable limted use of regex in the find/replace dialog.
In SQL Server 2012:
Highlight the selected text and use 'Find and Replace' (ctrl + h)
Check: use Regular Expressions
Find: \n
Replace with: LEAVE BLANK

Mgmt Studio save results as issue

I have a SQL query that returns 1 column. I run it in SQL Server Management Studio 2008R2.
I use File\Save Grid Results and create a .TXT file.
My problem is the first record of the file has 3 bytes inserted in front of the data. They three bytes are x'EFBBBF'. This causes problem when I use the file in another process.
I get the same thing wheter I save as .TXT or as .CSV.
Any ideas?
Found it.
Save Results As...
Choose a folder
Enter a file name
Save button now has a dropdown arrow to the right
Click on dropdown arrow and select Save with Encoding...
Select ANSI
Click OK
The ANSI-encoded file will not contain a UTF-8 BOM.
kuru kuru na is on the right track, those bytes are the UTF-8 BOM. I haven't found any settings to change the file encoding that Management Studio uses for saving results. I just use Vim to remove the BOM after saving the file. Your favorite text editor may have a similar option, or you could use a tool like iconv if you need to remove the mark or re-encode the file in a script.
I think it's called a "bom" (byte order mark) signature, which has something to do with telling whatever reads your file that it contains utf characters. I suspect it might be in your SMSS settings somewhere. But at least this is a place to start.

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars:
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.*/
This works quite well. However, the problem is that I would prefer it if it only worked on certain file types. Basically, any programming language should be highlighted and things like html, xml, and txt files should not be. I'm pretty sure I could do this easily with an autocmd, but I'm not sure if that is the best way to accomplish that goal. Anybody have any opinions?
Sounds like you might want something like:
autocmd FileType html,xml highlight OverLength ctermbg=red ctermfg=white guibg=#592929
autocmd FileType html,xml match OverLength /\%81v.*/
Seems to work for me anyway :-)
The issue with using match for a task like this is that it is local to the active window, not to the buffer being edited. I'd try something along the following lines:
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
fun! UpdateMatch()
if &ft !~ '^\%(html\|xml\)$'
match OverLength /\%81v.*/
else
match NONE
endif
endfun
autocmd BufEnter,BufWinEnter * call UpdateMatch()
Basically, you want to trigger whenever the buffer in the current window changes. At that point, you evaluate what filetype the buffer has and adjust whether the match should be active or not.
If you also want to support editing an unnamed buffer and then setting its filetype (either via saving or manually setting &ft), the FileType even should be added to the list.