byte-order-mark

Python Load UTF-8 JSON

前提是你 提交于 2019-12-02 18:40:10
问题 I have the following JSON (for simplicity's sake I'll only use one but there are 100 entries in reality): { "Active": false, "Book": "US Derivat. London, Mike Übersax/Michael Jealous", "ExpirationDate": "2006-10-12", "Isin": "CH0013096497", "IssueDate": "2001-10-09", "KbForXMonths": "0", "KbPeriodDay": "Period", "KbType": "Prozent", "KbYear": "0.5", "Keyinvest_IssueRetro": "0.50%", "Keyinvest_RecurringRetro": "1.00% pro rata temporis", "Keyinvest_RetroPayment": "Every month", "LastImportDate"

Python Load UTF-8 JSON

喜欢而已 提交于 2019-12-02 07:41:39
I have the following JSON (for simplicity's sake I'll only use one but there are 100 entries in reality): { "Active": false, "Book": "US Derivat. London, Mike Übersax/Michael Jealous", "ExpirationDate": "2006-10-12", "Isin": "CH0013096497", "IssueDate": "2001-10-09", "KbForXMonths": "0", "KbPeriodDay": "Period", "KbType": "Prozent", "KbYear": "0.5", "Keyinvest_IssueRetro": "0.50%", "Keyinvest_RecurringRetro": "1.00% pro rata temporis", "Keyinvest_RetroPayment": "Every month", "LastImportDate": "2008-12-31", "LiberierungDate": "1900-01-01", "NominalCcy": "USD", "NominalStueck": "5,000",

Modify a JSON file with PowerShell without writing BOM

允我心安 提交于 2019-12-02 02:32:34
I need to modify an existing UTF8 encoded JSON file with PowerShell. I tried with the following code: $fileContent = ConvertFrom-Json "$(Get-Content $filePath -Encoding UTF8)" $fileContent.someProperty = "someValue" $fileContent | ConvertTo-Json -Depth 999 | Out-File $filePath This adds a BOM to the file and also encodes it in UTF16. Is it possible to have ConvertFrom-Json and ConvertTo-Json do not do the encoding / BOM? Ansgar Wiechers This has nothing to do with ConvertTo-Json or ConvertFrom-Json . The encoding is defined by the output cmdlet. Out-File defaults to Unicode, Set-Content to

Adding BOM to CSV file using fputcsv

谁都会走 提交于 2019-12-01 17:56:40
I have a simple CSV file being generated that includes foreign characters. I've noted that if I don't include a Byte Order Mark that the foreign characters aren't appearing properly in Excel (but they appear fine when a BOM is present). How can I add a BOM to the beginning of the file when it's first created? I've tried the following and it's not working :-/ function processForm($competition, $competitionEntry) { $BOM = "\xEF\xBB\xBF"; // UTF-8 BOM $filename = $competition->ID.".csv"; $file = "entries/".$filename; $fields = array_keys($competitionEntry); $submittedForm = $competitionEntry; if

Adding BOM to CSV file using fputcsv

流过昼夜 提交于 2019-12-01 17:41:22
问题 I have a simple CSV file being generated that includes foreign characters. I've noted that if I don't include a Byte Order Mark that the foreign characters aren't appearing properly in Excel (but they appear fine when a BOM is present). How can I add a BOM to the beginning of the file when it's first created? I've tried the following and it's not working :-/ function processForm($competition, $competitionEntry) { $BOM = "\xEF\xBB\xBF"; // UTF-8 BOM $filename = $competition->ID.".csv"; $file =

Inno Setup replace a string in a UTF-8 file without BOM

别说谁变了你拦得住时间么 提交于 2019-12-01 09:56:00
问题 I need to change some values in a configuration file. The file is UTF-8 without BOM. I need to save it the same way. How do I do it with Inno Setup Unicode edition? Note: This doesn't work, and this doesn't show how to read the file correctly. 回答1: const CP_UTF8 = 65001; { ... } var FileName: string; S: string; begin FileName := 'test.txt'; if not LoadStringFromFileInCP(FileName, S, CP_UTF8) then begin Log('Error loading the file'); end else if StringChangeEx(S, 'žluťoučký kůň', 'ďábelské ódy

BOM randomly appears in JSON reply

不打扰是莪最后的温柔 提交于 2019-12-01 09:19:35
I'm implementing communication between two servers using JSON and cURL. The problem is, that sometimes there's BOM (byte order mark), appended before opening bracket in JSON reply. I've managed to trim it and successfully parse JSON string, but considering that JSON is generated by my own code, I've no idea, where does that BOM come from. I'm using json_encode() to generate reply and header() + echo to print it, an as far as I cant tell, json_decode() does not produce any BOMs. Corresponding .php files are encoded in UTF-8 and have no BOM in them (according to Notepad++). Apart from cURL, I've

Unwanted new line returned after AJAX request

☆樱花仙子☆ 提交于 2019-12-01 07:35:36
I'm using an ajax request to send comments to DB. Succesful response is marked by 1. OK The problem actually is that the response from the php script is 1. 2. OK So I debugged the script and noted that the newline character si being added when the script executes the following line: require_once($ABS_APPS."/quotes/classQuote.php"); After some searches i read that it could be a BOM (Byte Order Mark) problem. So I just downloaded and opened the classQuote.php file with an hex editor and noticed that there's no BOM... can someone help me? P.S. All files in my project are encoted in UTF-8, and I'm

Does Java have methods to get the various byte order marks?

删除回忆录丶 提交于 2019-12-01 07:04:56
I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like: byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark(); Where CharEncoding comes from Apache Commons. Java does not recognize byte order marks for UTF-8. See bugs 4508058 and 6378911 . The gist is that support was added, broke backwards compatibility, and was rolled back. You'll have to do BOM recognition in UTF-8 yourself. Chris Carcel Apache

Does Java have methods to get the various byte order marks?

大兔子大兔子 提交于 2019-12-01 05:22:28
问题 I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like: byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark(); Where CharEncoding comes from Apache Commons. 回答1: Java does not recognize byte order marks for UTF-8. See bugs 4508058 and 6378911. The gist is that support was added, broke backwards