utf-16

Encoding issue: An NSString into a key of an NSDictionary

╄→гoц情女王★ 提交于 2019-12-11 10:03:57
问题 So I'm taking a data file and encoding it into a string: /////////////////////////////// // Get the string NSString* dataString = [[NSString alloc] initWithData:data encoding:encoding]; NSLog(@"dataString = %@",dataString); The file was a list of French words and they NSLog fine, showing appropriate accents (just one example): abandonnèrent Now, in the very next part of the code I take this NSString of the file contents and convert it to a dictionary where the words are the keys and the

Send UTF-16 encoded SOAP request with Ruby and Savon

﹥>﹥吖頭↗ 提交于 2019-12-11 05:01:46
问题 How do I encode the request in UTF-16? Here's what I have: # Create Savon client @client = Savon::Client.new do wsdl.document = File.expand_path("account_list.wsdl", __FILE__) end # Set header encoding @client.http.headers["Content-Type"] = "text/xml;charset=UTF-16" # Setup ssl configuration @client.http.auth.ssl.cert_key_file = "cert_key_file.pem" @client.http.auth.ssl.cert_file = "cert_file.pem" @client.http.auth.ssl.ca_cert_file = "ca_cert_file.pem" @client.http.auth.ssl.verify_mode=:none

SQLite - Insert special symbols (trademark, …) into table

偶尔善良 提交于 2019-12-11 02:42:24
问题 How can I insert special symbols like trademark into SQLite table? I have tried to use PRAGMA encoding = "UTF-16" with no effect :( 回答1: Typically if you surround an SQL entry with ''Single quotes, it goes in as a literal. i.e. '™' 回答2: problem solved. it is necessary to open DB file with sqlite3_open16, then execute command PRAGMA encoding = \"UTF-16\"; (I am not sure, if it is necessary). Now the insert will be done with UTF-16. To select from db (to get column value) is necessary to use

Ruby: how to save file to UTF-16 Little Endian

守給你的承諾、 提交于 2019-12-10 19:23:00
问题 I want to save ® into a txt file with UTF-16 Little Endian, I tested in some ways 1.The encoding below is UTF-8 $RegisterMark=[174].pack('U*') file = File.new("C:/Output.txt","w") file.puts $RegisterMark file.close 2.The encoding below is UTF-16 Big Endian require 'iconv' $RegisterMark=[174].pack('U*') $utf16RegisterMark =Iconv.conv('UTF-16', 'UTF-8', $RegisterMark ) file = File.new("C:/Output.txt","w") file.puts $utf16RegisterMark file.close The mentod Iconv.conv doesn't suport UTF-16 LE

Converting file in UTF-8 to UTF-16

让人想犯罪 __ 提交于 2019-12-10 18:55:47
问题 A program in C++ needs to read a file that is encoded in utf-8. Unfortunately, using char* it cannot get extended characters (☺☻♥♦•◘ and so on), and wchar_t* interprets them wrongly. My algorithm to manage it is: 1) Make a new file 2) Name it to [original name]Utf-16 3) Copy original file to new, making a conversion simultaneously 4) Extract data. 5) Delete this temporary file when it's no longer needed. I'm stuck at 3), is there somewhere a function like "FileUTF8toUTF16"? 回答1: This is what

UTF-16 codecvt facet

こ雲淡風輕ζ 提交于 2019-12-10 18:46:06
问题 Extending from this questions about locales And described in this question: What I really wanted to do was install a codecvt facet into the locale that understands UTF-16 files. I could write my own. But I am not a UTF expert and as such I am sure I would get it nearly correct; but it would break at the most inconvenient time. So I was wondering if there are any resources (on the web) of pre-build codecvt (or other) facets that can be used from C++ that are peer reviewed and tested? The

Detect (or best guess of) incoming string encoding in Java

不羁岁月 提交于 2019-12-10 17:14:47
问题 I was wondering if there are known methods to detect (or give a best guess of) the encoding of a particular string in Java. I know that you always need some additional meta-data to tell what the encoding is, and there are best practices etc., but the situation I'm in, I need to give the best approximation. A solution -- or a pointer -- to programatically distinguishing between UTF-8 and UTF-16 is also welcome. 回答1: The utf-8 encoding should be easy to verify: UTF-8 strings can be fairly

What character encoding does ObjectOutputStream 's writeObject method use?

。_饼干妹妹 提交于 2019-12-10 16:15:52
问题 I read that Java uses UTF-16 encoding internally. i.e. I understand that if I have like: String var = "जनमत"; then the "जनमत" will be encoded in UTF-16 internally. So, If I dump this variable to some file such as below: fileOut = new FileOutputStream("output.xyz"); out = new ObjectOutputStream(fileOut); out.writeObject(var); will the encoding of the string "जनमत" in the file "output.xyz" be in UTF-16? Also, later on if I want to read from the file "output.xyz" via ObjectInputStream, will I be

How to read utf-16 file into utf-8 std::string line by line

◇◆丶佛笑我妖孽 提交于 2019-12-10 15:42:07
问题 I'm working with code that expects utf8-encoded std::string variables. I want to be able to handle a user-supplied file that potentially has utf-16 encoding (I don't know the encoding at design time, but eventually want to be able to deal with utf8/16/32), read it line-by-line, and forward each line to the rest of the code as a utf8-encoded std::string. I have c++11 (really, the current MSVC subset of c++11) and boost 1.55.0 to work with. I'll need the code to work on both Linux and Windows

How do I accomplish random reads of a UTF8 file

别等时光非礼了梦想. 提交于 2019-12-10 14:54:00
问题 My understanding is that reads to a UTF8 or UTF16 Encoded file can't necessarily be random because of the occasional surrogate byte (used in Eastern languages for example). How can I use .NET to skip to an approximate position within the file, and read the unicode text from a semi-random position? Do I discard surrogate bytes and wait for a word break to continue reading? If so, what are the valid word breaks I should wait for until I start the decoding? 回答1: Easy, UTF-8 is self-synchronizing