byte-order-mark

Git ignore BOM (prevent git diff from showing byte order mark changes)

霸气de小男生 提交于 2019-11-27 07:41:06
问题 I want git diff to not show BOM changes. Such changes typically show up as <feff> in the diff: -<feff>/*^M +/*^M How can I make git diff to behave this way? Preferably with a command-line parameter. git --ignore-all-space (aka git -w ) does not do the trick. I am on Mac OS X if that matters. 回答1: Use Git Attributes filter One possible solution would be to create a BOM filter such as: #!/bin/bash sed '1s/^\xEF\xBB\xBF//' "$1" store it somewhere in your path (as i.e. removebom ) and make it

Read a UTF-8 text file with BOM

删除回忆录丶 提交于 2019-11-27 07:40:48
I have a text file with Byte order mark (U+FEFF) at the beginning. I am trying to read the file in R. Is it possible to avoid the Byte order mark? The function fread (from the data.table package) reads the file, but adds  at the beginning of the first variable name: > names(frame_pers)[1] [1] "reg_date" The same is with read.csv function. Currently I have made a function which removes the BOM from the first column name, but I believe there should be a way how to automatically strip the BOM. remove.BOM <- function(x) setnames(x, 1, substring(names(x)[1], 4)) > names(frame_pers)[1] [1] "ļ

Is it possible to get GCC to compile UTF-8 with BOM source files?

让人想犯罪 __ 提交于 2019-11-27 05:54:34
问题 I develop C++ cross platform using Microsoft Visual Studio on Windows and GCC on uBuntu Linux. In Visual Studio I can use unicode symbols like " π " and " ² " in my code. Visual Studio always saves the source files as UTF-8 with BOM (Byte Order Mark). For example: // A = π.r² double π = 3.14; GCC happily compiles these files only if I remove the BOM first. If I do not remove the BOM, I get errors like these: wwga_hydutils.cpp:28:9: error: stray ‘\317’ in program wwga_hydutils.cpp:28:9: error:

heroku not loading language file

若如初见. 提交于 2019-11-27 04:42:41
问题 Heroku does not seem to be loading config/locales/pt.yml . (Language is being set correctly to pt .) I18n is working perfectly on localhost, but not on my heroku server. Code is at https://github.com/aneves/deficit-puzzle localhost: $ rails console Loading development environment (Rails 3.0.5) irb(main):001:0> I18n.t(:Edit) => "Editar" heroku: $ heroku console Ruby console for deficit-puzzle.heroku.com >> I18n.t(:Edit) => "translation missing: pt.Edit" possible dups: There are SO matches for

Create Text File Without BOM

心已入冬 提交于 2019-11-27 04:03:52
问题 I tried this aproach without any success the code I'm using: // File name String filename = String.Format("{0:ddMMyyHHmm}", dtFileCreated); String filePath = Path.Combine(Server.MapPath("App_Data"), filename + ".txt"); // Process myObject pbs = new myObject(); pbs.GenerateFile(); // pbs.GeneratedFile is a StringBuilder object // Save file Encoding utf8WithoutBom = new UTF8Encoding(true); TextWriter tw = new StreamWriter(filePath, false, utf8WithoutBom); foreach (string s in pbs.GeneratedFile

R's read.csv prepending 1st column name with junk text [duplicate]

空扰寡人 提交于 2019-11-27 03:53:16
问题 This question already has answers here : When I import text file into R, I get a special character appended to the first value of the first column (3 answers) Closed 2 years ago . I have exported data from a result grid in SQL Server Management Studio to a csv file. The csv file looks correct. But when I read the data into an R dataframe using read.csv, the first column name is prepended with " ï.. ". How do I get rid of this junk text? Example: str(trainData) 'data.frame': 64169 obs. of 20

Adding UTF-8 BOM to string/Blob

怎甘沉沦 提交于 2019-11-27 03:49:25
I need to add a UTF-8 byte-order-mark to generated text data on client side. How do I do that? Using new Blob(['\xEF\xBB\xBF' + content]) yields '"my data"' , of course. Neither did '\uBBEF\x22BF' work (with '\x22' == '"' being the next character in content ). Is it possible to prepend the UTF-8 BOM in JavaScript to a generated text? Yes, I really do need the UTF-8 BOM in this case. Erik Töyrä Silfverswärd Prepend \ufeff to the string. See http://msdn.microsoft.com/en-us/library/ie/2yfce773(v=vs.94).aspx See discussion between @jeff-fischer and @casey for details on UTF-8 and UTF-16 and the

How Can I Best Guess the Encoding when the BOM (Byte Order Mark) is Missing?

风流意气都作罢 提交于 2019-11-27 03:27:51
My program has to read files that use various encodings. They may be ANSI, UTF-8 or UTF-16 (big or little endian). When the BOM (Byte Order Mark) is there, I have no problem. I know if the file is UTF-8 or UTF-16 BE or LE. I wanted to assume when there was no BOM that the file was ANSI. But I have found that the files I am dealing with often are missing their BOM. Therefore no BOM may mean that the file is ANSI, UTF-8, UTF-16 BE or LE. When the file has no BOM, what would be the best way to scan some of the file and most accurately guess the type of encoding? I'd like to be right close to 100%

How do I encode/decode UTF-16LE byte arrays with a BOM?

无人久伴 提交于 2019-11-27 02:12:16
问题 I need to encode/decode UTF-16 byte arrays to and from java.lang.String . The byte arrays are given to me with a Byte Order Marker (BOM), and I need to encoded byte arrays with a BOM. Also, because I'm dealing with a Microsoft client/server, I'd like to emit the encoding in little endian (along with the LE BOM) to avoid any misunderstandings. I do realize that with the BOM it should work big endian, but I don't want to swim upstream in the Windows world. As an example, here is a method which

Remove a BOM character in a file

∥☆過路亽.° 提交于 2019-11-27 02:08:08
I have a BOM character in my html file. I want to remove It. I have searched a lot and used a lot of scripts and etc... . But no one worked. I have downloaded notepad++ too, but there is not encoding "UTF8 without BOM" in its encoding menu. How can I delete that BOM character? thanks. If you look in the same menu. Click "Convert to UTF-8." You can solve the problem using vim, where you can get easily with MinGW-w64 (If you have installed Git it comes along) or Cygwin. So, the key is to use: The option -s , which will execute a vim script with vim commands. The option -b , which will open your