utf-16

Writing utf16 to file in binary mode

前提是你 提交于 2019-12-17 04:29:05
问题 I'm trying to write a wstring to file with ofstream in binary mode, but I think I'm doing something wrong. This is what I've tried: ofstream outFile("test.txt", std::ios::out | std::ios::binary); wstring hello = L"hello"; outFile.write((char *) hello.c_str(), hello.length() * sizeof(wchar_t)); outFile.close(); Opening test.txt in for example Firefox with encoding set to UTF16 it will show as: h�e�l�l�o� Could anyone tell me why this happens? EDIT: Opening the file in a hex editor I get: FF FE

Can I make git recognize a UTF-16 file as text?

橙三吉。 提交于 2019-12-16 22:35:13
问题 I'm tracking a Virtual PC virtual machine file (*.vmc) in git, and after making a change git identified the file as binary and wouldn't diff it for me. I discovered that the file was encoded in UTF-16. Can git be taught to recognize that this file is text and handle it appropriately? I'm using git under Cygwin, with core.autocrlf set to false. I could use mSysGit or git under UNIX, if necessary. 回答1: I've been struggling with this problem for a while, and just discovered (for me) a perfect

PrintStream doesn't print correctly unicode characters ( UTF-16)

杀马特。学长 韩版系。学妹 提交于 2019-12-14 03:58:42
问题 I want to print correctly unicode (let's say greek characters ) but I have problems. For example : PrintStream oStream = new PrintStream(client.getOutputStream(), true, "UTF-8"); oStream.write(" Customer : Γειά σου\r\n".getBytes()); oStream.write(" ΚΩΔΙΚΟΣ : 00000234242\r\n".getBytes()); oStream.flush(); oStream.close(); OR OutputStreamWriter oStream = new OutputStreamWriter(client.getOutputStream(), "UTF-16"); oStream.write(" Customer : Γειά σου\r\n"); oStream.write(" ΚΩΔΙΚΟΣ : 00000234242\r

Visual Studio GlobalSuppression.cs file and UTF-16

China☆狼群 提交于 2019-12-14 03:44:03
问题 It seems that Visual Studio 2015 saves the GlobalSuppression.cs file using a UTF-16 encoding. This is annoying when using SVN as it perceives that a UTF-16 file is a binary file. Questions: Using Visual Studio, is it possible to save GlobalSuppression.cs with a UTF-8 encoding? Alternatively, can someone provide a location where I can find the template that this file is based on (if one exists)? Note that I can't find a template in Common7\IDE\ItemTemplates . 回答1: To change the encoding of the

How does Apache commons IO convert my XML header from UTF-8 to UTF-16?

半城伤御伤魂 提交于 2019-12-14 02:41:58
问题 I’m using Java 6. I have an XML template, which begins like so <?xml version="1.0" encoding="UTF-8"?> However, I notice when I parse and output it with the following code (using Apache Commons-io 2.4) … Document doc = null; InputStream in = this.getClass().getClassLoader().getResourceAsStream(“my-template.xml”); try { byte[] data = org.apache.commons.io.IOUtils.toByteArray( in ); InputSource src = new InputSource(new StringReader(new String(data))); DocumentBuilderFactory factory =

Python CSV file UTF-16 to UTF-8 print error

风格不统一 提交于 2019-12-13 15:35:20
问题 There is a number of topics on this problem around the web, but I can not seem to find the answer for my specific case. I have a CSV file. I am not sure what was was done to it, but when I try to open it, I get: UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte Here is a full Traceback : Traceback (most recent call last): File "keywords.py", line 31, in <module> main() File "keywords.py", line 28, in main get_csv(file_full_path) File "keywords.py", line

How can I get a simple c# web service to return <?xml version=“1.0” encoding=“utf-16” ?> header?

时光怂恿深爱的人放手 提交于 2019-12-13 02:39:13
问题 I've written a very simple web service that returns an XML document. The header for that document is currently <?xml version="1.0" encoding="utf-8" ?> and I would like it to return <?xml version="1.0" encoding="utf-16" ?> How can I change the default output encoding in the .asmx or .cs file? smo.asmx <%@ WebService Language="C#" Class="smo" %> smo.asmx using <blah> [WebService(Namespace="http://www.bl.uk/webservices/")] public class smo : WebService { [XmlRoot(ElementName = "SQLServer")]

grep unicode 16 support

妖精的绣舞 提交于 2019-12-12 17:24:14
问题 I use TextEdit on macosx created two files, same contents with different encodings, then grep xxx filename_UTF-16 nothing grep xxx filename_UTF-8 xxxxxxx xxxxxxyyyyyy grep did not support UTF-16? 回答1: iconv -f UTF-16 -t UTF-8 yourfile | grep xxx 回答2: You could always try converting first to utf-8: iconv -f utf-16 -t utf-8 filename | grep xxxxx 回答3: Use ripgrep utility instead of grep which can support grepping UTF-16 files. Install by: brew install ripgrep. Then run: rg xxx filename_UTF-16

Displaying UTF-16 characters on web browser

可紊 提交于 2019-12-12 15:40:47
问题 I printed some UTF-16 encoded characters and tried to display it in Firefox and it displayed it as �. So I went to Tools->Encoding and changed the encoding from UTF-8 to UTF-16 (I also tried changing charset directly in the HTML) However, when I did that, my page was completely flooded with symbols: ਍ℼ佄呃偙⁅瑨汭ാ㰊瑨汭ാഊ㰊敨摡ാ †ഠ †㰠楴汴㹥楬畮⁸‭楆敲潦⁸楤灳慬獹朠牡慢敧挠慨慲瑣牥⁳湩氠敩⁵景眠扥 瀠条⁥‭畓数⁲獕牥⼼楴汴㹥਍††氼湩敲㵬猢潨瑲畣⁴捩湯•牨晥∽瑨灴⼺振湤献瑳瑡捩渮瑥猯灵牥獵牥椯杭是癡捩湯椮潣㸢਍††氼湩敲㵬愢灰敬琭畯档椭潣≮栠敲㵦栢瑴㩰⼯摣⹮獳慴楴⹣敮............ How can web browsers display UTF-16

How to Print UTF-16 Characters in C?

不打扰是莪最后的温柔 提交于 2019-12-12 11:12:58
问题 i have a file containing UTF-16 characters. i read in the file and can store the characters either in a uint16_t array or a char array (any better choice?) But how do i print those characters? 回答1: I'm assuming you want to print to stdout or stderr . One method would be to use libiconv to convert from UTF-16 to UTF-32 (also known as UCS-4) into a wide-character string ( wchar_t ). You could then use wprintf and friends to print to the standard streams. 来源: https://stackoverflow.com/questions