byte-order-mark

Is it possible to run a SQLPLUS script on a file encoded as UTF-8 with BOM

北城以北 提交于 2019-12-01 04:01:49
I'm trying to run a collection of scripts which have been auto-generated from a large number of sources. Unfortunately some of these have been generated as UTF-8 with BOM. I have in place a system for automatically removing the BOM, but its a bit of a messy process. Failing to remove the BOM generates the error: SP2-0042: unknown command "" - rest of line ignored. Is it possible to run SQLPLUS on a script file which has a BOM? It is possible to run SQLPLUS with such script, but SQLPLUS will indicate an error on the first line because of BOM . Probably you wanted to ask if you can avoid this

UTF8 Python BOM [duplicate]

时间秒杀一切 提交于 2019-12-01 00:47:47
Possible Duplicate: Write to utf-8 file in python I have Unicode strings (with Japanese characters) I want to write to a CSV file. However, the BOM does not seem to be written correctly, just as a string "" in the first line. This leads to Excel not displaying the Japanese characters correctly. When opening the CSV with Notepad++, the characters are displayed correctly. fileObj = codecs.open(filename,"w",'utf-8') fileObj.write(codecs.BOM_UTF8) c = u';' for s in stringsToWrite: line = e.someUnicodeString fileObj.write(line) fileObj.close() fileObj = codecs.open(filename,"w",'utf-8') OK, you

UTF8 Python BOM [duplicate]

扶醉桌前 提交于 2019-11-30 19:55:54
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Write to utf-8 file in python I have Unicode strings (with Japanese characters) I want to write to a CSV file. However, the BOM does not seem to be written correctly, just as a string "" in the first line. This leads to Excel not displaying the Japanese characters correctly. When opening the CSV with Notepad++, the characters are displayed correctly. fileObj = codecs.open(filename,"w",'utf-8') fileObj.write

 enconding issue

空扰寡人 提交于 2019-11-30 18:54:21
I'm developing a website using PHP and these strange chars "" appears in my page, right on the top of it. My code is this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?php echo '';?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> But when I see the source code in the browser, it shows this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www

How to write BOM marker to a file in Ruby

丶灬走出姿态 提交于 2019-11-30 17:49:45
I have some working code with a crutch to add BOM marker to a new file. #writing File.open name, 'w', 0644 do |file| file.write "\uFEFF" file.write @data end #reading File.open name, 'r:bom|utf-8' do |file| file.read end Is there any way to automatically add the marker without writing cryptic "\uFEFF" before the data? Something like File.open name, 'w:bom' # this mode has no effect maybe? Alas I think your manual approach is the way to go, at least I don't know a better way: http://blog.grayproductions.net/articles/miscellaneous_m17n_details To quote from JEG2's article: Ruby 1.9 won't

Remove BOM from string with Perl

时间秒杀一切 提交于 2019-11-30 17:31:23
I have the following problem: I am reading from a UTF-8 text file (and I am telling Perl that I am doing so by ":encoding(utf-8)"). The file looks like this in a hex viewer: EF BB BF 43 6F 6E 66 65 72 65 6E 63 65 This translates to "Conference" when printed. I understand the "wide character" which I am being warned about is the BOM. I want to get rid of it (not because of the warning, but because it messes up a string comparison that I undertake later). So I tried to remove it using the following code, but I fail miserably: $line =~ s/^\xEF\xBB\xBF//; Can anyone enlighten me as to how to

How to write BOM marker to a file in Ruby

柔情痞子 提交于 2019-11-30 16:52:54
问题 I have some working code with a crutch to add BOM marker to a new file. #writing File.open name, 'w', 0644 do |file| file.write "\uFEFF" file.write @data end #reading File.open name, 'r:bom|utf-8' do |file| file.read end Is there any way to automatically add the marker without writing cryptic "\uFEFF" before the data? Something like File.open name, 'w:bom' # this mode has no effect maybe? 回答1: Alas I think your manual approach is the way to go, at least I don't know a better way: http://blog

python utf-8-sig BOM in the middle of the file when appending to the end

微笑、不失礼 提交于 2019-11-30 15:20:34
问题 I've noticed recently that Python behaves in such non-obvious way when appending to the file using utf-8-sig encoding. See below: >>> import codecs, os >>> os.path.isfile('123') False >>> codecs.open('123', 'a', encoding='utf-8-sig').write('123\n') >>> codecs.open('123', 'a', encoding='utf-8-sig').write('123\n') The following text ends up to the file: <BOM>123 <BOM>123 Isn't that a bug? This is so not logical. Could anyone explain to me why it was done so? Why didn't they manage to prepend

python utf-8-sig BOM in the middle of the file when appending to the end

房东的猫 提交于 2019-11-30 14:17:31
I've noticed recently that Python behaves in such non-obvious way when appending to the file using utf-8-sig encoding. See below: >>> import codecs, os >>> os.path.isfile('123') False >>> codecs.open('123', 'a', encoding='utf-8-sig').write('123\n') >>> codecs.open('123', 'a', encoding='utf-8-sig').write('123\n') The following text ends up to the file: <BOM>123 <BOM>123 Isn't that a bug? This is so not logical. Could anyone explain to me why it was done so? Why didn't they manage to prepend BOM only when file doesn't exist and needs to be created? No, it's not a bug; that's perfectly normal,

Remove BOM from string in Java

喜你入骨 提交于 2019-11-30 07:31:44
问题 I have string in file, that contains BOM (from UTF-8). I want to convert this string to win-1251 and put it in file. I trying to remove BOM from string in this way: out.write(l.replace('\uFEFF','\0') + "\n"); But it don't work. Why? Output of this string in win-1251 file: ?1,...SOME_TEXT_HERE First "?" sign is illegal. 回答1: You're replacing the BOM with U+0000, rather than with an empty string. You should replace the BOM with the empty string, e.g. out.write(l.replace("\uFEFF", "") + "\n");