I try to run script (.read FILE) that has UTF-8 strings. I used pragma command:
PRAGMA encoding="UTF-8";
But I get wrong characters.
If I create table and insert values by myself, everything works right. What should I do to run script properly?
By the way, I checked a lot of questions/articles on stackoverflow and other resources + read documentation. I tried some methods, for example, to use chcp 65001 in Windows cmd and then opened sqlite3 in current window. But it didn't help.
The PRAGMA encoding setting does not change how you use the SQLite API. And the encoding of an existing DB cannot be changed.
Don't use it.
The sqlite3.exe command-line shell does not work with UTF-8 characters. (Except maybe in the latest version.)
Don't use it.
If your own scripts and applications use strings encoded in UTF-8, and if you use any tool except sqlite3.exe to check the resulting DB, then it will work.
All you need to do is:
Open cmd and change encoding (chcp 65001)
Run sqlite3.exe from current windows
Change encoding (PRAGMA encoding="UTF-8";)
Create correct UTF-8 script.
Related
My goal is to open image files in a default image viewer (Windows 10 Photos app), and close them per user input. My file path contains backslashes, not standard slashes, although replacing them doesn't seem to change the results I mention below.
I tried the following:
Kernel.system('full_path_to_image')
or the same thing using exec instead, but it simply returns a format error Errno::ENOEXEC. Manually entering the file path in the command interpreter works even if the interpreter is opened via:
Kernel.system('cmd')
I tried to avoid the shell by using a multi-argument version of system, but I could not.
Is it possible to do what I want to?
According to this answer, this should work on windows.
system("start #{path_to_image}")
I am used to working within pgAdmin, open a SQL script and just type there. I figured out how to run some scripts after each other with a batch file but ran into the problem that I needed UTF-8 without BOM. I fixed that by opening the scripts in notepad++ and saving them in UTF-8 without BOM.
But now whenever I work on a script within pgAdmin and then want to run it from the batch file, I have to do the same routine with notepad++. Isn't there a way to save UTF-8 without BOM in pgAdmin? Or to set the type of the scripts in UTF-8 without BOM that it is the default value and will never change?
In pgAdmin III (pgadmin3) version 1.14 and later, you can control this with a global setting:
Open the options dialog, e.g. with menu File → Options
Go to section Query tool → Query file
Uncheck checkbox Write BOM for UTF files
If you already had "Query tool" windows open in pgAdmin, you might have to close them and reopen the scripts in new "Query tool" windows for the change to take effect on subsequent saves.
I'm on Win10 and I have a .bat file to rename a bunch of files. Some of the entries need to be renamed to a non-English name, e.g.
RENAME "MyFile1.txt" "Eisenhüttenstadt.txt"
However, when I run this, the 'ü' comes out as something else, other characters with an umlaut also are replaced by different characters.
I've tried saving the .bat file in Notepad with Unicode and UTF-8 encoding but then Windows doesn't recognise the command when I try to run it.
I've read this and other similar issues but not found a solution, surely it's simple when you know how?
Any suggestions?
The default code page in the console is 437(USA) or 850(Europe), which does not support characters with umlaut, so you must change this to 1252(West European Latin). So, use Chcp command in the beginning of your batch file to change it, like this:
Chcp 1252
Example:
image via http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-7-umlaute-in-batch-dateien-55616/
Sources:http://ss64.com/nt/chcp.html , http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-7-umlaute-in-batch-dateien-55616/ (The article says for Windows 7 but this applies for Windows 10 too)
I am trying to get a batch file to work. Whenever I attempt to run a .bat the command line returns '■m' is not recognized... error, where "m" is the first letter of the file. For example:
md c:\testsource
md c:\testbackup
Returns
C:>"C:\Users\Michael\Dropbox\Documents\Research\Media\Method Guide\Program\test
.bat"
C:>■m
'■m' is not recognized as an internal or external command,
operable program or batch file.
Things I have tried:
Changing Path variables, rebooting, etc.
Changing file directory (i.e. run from C:)
Running example files from web (like above) to check for syntax errors.
Thanks
What text editor are you writing this in? It seems like your text editor may save the file as UTF-16 encoded text, which cmd.exe can't handle. Try setting the "coding"/"file encoding" to "ANSI" when saving the file.
This results in the first byte being a byte-order-mark (telling other editors how to process the file), and cmd.exe can't deal with this.
In addition to the approved answer I would add the case where is a PowerShell command the one that creates the file... PowerShell comes by default with the UTF-16 encoding.
To solve your problem then, force the file encoding lie this: | out-file foo.txt -encoding utf8
Answer based on this other answer.
In windows 10 I had the same issue.
Changing the character set to UTF-8 made it worse.
It worked correctly when I selected Encoding as UTF-8-NO BOM.
I need to execute a command like vlc 舨.avi programatically on Windows. When done directly in cmd.exe this works just fine, proving that VLC has the capability to recognize unicode arguments. However, I'm having trouble putting this in a script and having it work.
Has anyone done this successfully? I would love to do this in Ruby (I have 1.9.2) but Python-win32, Perl-win32, batch, .cmd, VB/W/JScript are all options. Target O/Ses are XP and Vista.
It's most likely an encoding issue.
Encoding in command prompts and in windows is not always the same. If your script in Notepad, then execute it, you may end up with the filename being converted to unicode differently hence the error.
Somehow, you'll have to make sure that the encoding is correct, maybe by saving you batch file as Unicode text file? Would that work?