byte-order-mark

cURL gets response with utf-8 BOM

南笙酒味 提交于 2019-12-08 02:01:13
问题 In my script I send data with cURL, and enabled CURLOPT_RETURNTRANSFER. The response is json encoded data. When I'm trying to json_decode, it returns null. Then I found that response contains utf-8 BOM symbols at the beginning of string (). There is some experiments: $data = $data = curl_exec($ch); echo $data; the result is {"field_1":"text_1","field_2":"text_2","field_3":"text_3"} $data = $data = curl_exec($ch); echo mb_detect_encoding($data); result - UTF-8 $data = $data = curl_exec($ch)

Java Spring returning CSV file encoded in UTF-8 with BOM

自闭症网瘾萝莉.ら 提交于 2019-12-08 01:20:38
问题 Apparently for excel to open CSV files nicely, it should have the Byte Order Mark at the start. The download of CSV is implemented by writing into HttpServletResponse 's output stream in the controller, as the data is generated during request. I get an exception when I try to write the BOM bytes - java.io.CharConversionException: Not an ISO 8859-1 character: [] (even though the encoding I specified is UTF-8 ). The controller's method in question @RequestMapping("/monthly/list") public List

UTF8 encoding without BOM - PowerShell

给你一囗甜甜゛ 提交于 2019-12-08 00:42:38
问题 I have a bat file where I encode some CSV files. The problem is that there are one character at the begining of the file once the encoding have been done (BOM byte I guess). This character bothers me cause after encoding, I use this file to generate a database. Here is the line for encoding (inside bat file): powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\pass.csv Is there any way to encode the file without BOM (if this is the problem)??

XML file output only shows Byte Order Mark

扶醉桌前 提交于 2019-12-07 16:50:16
问题 I have an XML file that I am trying to parse, whose contents are exactly the XML below: <Results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Reference>{REFERENCE-HERE}</Reference> <FillerTags>Filler</FillerTags> <entity> <entityName>ABC</entityName> <entityId>012345</entityId> </entity> <Items> <Item> <FillerTagsAgain>Filler2</FillerTagsAgain> <FillerTagsAgain>Filler2</FillerTagsAgain> <FillerTagsAgain>Filler2</FillerTagsAgain> </Item>

cURL gets response with utf-8 BOM

会有一股神秘感。 提交于 2019-12-06 06:14:00
In my script I send data with cURL, and enabled CURLOPT_RETURNTRANSFER. The response is json encoded data. When I'm trying to json_decode, it returns null. Then I found that response contains utf-8 BOM symbols at the beginning of string (). There is some experiments: $data = $data = curl_exec($ch); echo $data; the result is {"field_1":"text_1","field_2":"text_2","field_3":"text_3"} $data = $data = curl_exec($ch); echo mb_detect_encoding($data); result - UTF-8 $data = $data = curl_exec($ch); echo mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data)); // identical to echo mb_convert

How can I remove any UTF-8 BOM that exists -within- some text, not at the start of some text

戏子无情 提交于 2019-12-06 05:28:00
We receive some files, which have been concatenated by another party. In the middle of these files are some BOM characters. Is there a way we can detect these 3 chars and remove them? I've seen plenty of examples about how to remove the BOM from the -start- of a file ... but not the middle. Assuming that your file is small enough to hold in memory, and that you have an Enumerable.Replace extension method for replacing subsequences, then you could use: var bytes = File.ReadAllBytes(filePath); var bom = new byte[] { 0xEF, 0xBB, 0xBF }; var empty = Enumerable.Empty<byte>(); bytes = bytes.Replace

PHP Include function outputting unknown char

情到浓时终转凉″ 提交于 2019-12-06 05:25:01
问题 When using the php include function the include is succesfully executed, but it is also outputting a char before the output of the include is outputted, the char is of hex value 3F and I have no idea where it is coming from, although it seems to happen with every include. At first I thbought it was file encoding, but this doesn't seem to be a problem. I have created a test case to demonstrate it: ( link no longer working ) http://driveefficiently.com/testinclude.php this file consists of only

Java Spring returning CSV file encoded in UTF-8 with BOM

旧时模样 提交于 2019-12-06 04:47:06
Apparently for excel to open CSV files nicely, it should have the Byte Order Mark at the start. The download of CSV is implemented by writing into HttpServletResponse 's output stream in the controller, as the data is generated during request. I get an exception when I try to write the BOM bytes - java.io.CharConversionException: Not an ISO 8859-1 character: [] (even though the encoding I specified is UTF-8 ). The controller's method in question @RequestMapping("/monthly/list") public List<MonthlyDetailsItem> queryDetailsItems( MonthlyDetailsItemQuery query, @RequestParam(value = "format",

UTF8 encoding without BOM - PowerShell

99封情书 提交于 2019-12-06 04:36:01
I have a bat file where I encode some CSV files. The problem is that there are one character at the begining of the file once the encoding have been done (BOM byte I guess). This character bothers me cause after encoding, I use this file to generate a database. Here is the line for encoding (inside bat file): powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\pass.csv Is there any way to encode the file without BOM (if this is the problem)?? Thanks! I found the solution. Just change the line with this: powershell -Command "&{ param($Path);

How can I identify different encodings against files without the use of a BOM and beginning with non-ASCII character?

好久不见. 提交于 2019-12-06 03:44:38
问题 I got a problem when trying to identify the encoding of a file without BOM, particularly when the file is beginning with non-ascii characters. I found following two topics about how to identify encodings for files, How can I identify different encodings without the use of a BOM? Java: Readers and Encodings Currently, I created a class to identify different encodings for files (e.g. UTF-8, UTF-16, UTF-32, UTF-16 no BOM, etc) like following, public class UnicodeReader extends Reader { private