utf-8

Why filename has different bytes after converting UTF16 -> UTF8 -> UTF16 in winapi?

此生再无相见时 提交于 2020-01-04 05:36:28
问题 I have next file: I use ReadDirectoryChangesW for reading changes in current folder. And I get path to this file: L"TEST Ӡ⬨☐.ipt": Next, I want to convert this to utf8 and back: std::string wstringToUtf8(const std::wstring& source) { const int size = WideCharToMultiByte(CP_UTF8, 0, source.data(), static_cast<int>(source.size()), NULL, 0, NULL, NULL); std::vector<char> buffer8(size); WideCharToMultiByte(CP_UTF8, 0, source.data(), static_cast<int>(source.size()), buffer8.data(), size, NULL,

PHP DOMDocument::save() saves as ASCII instead of UTF-8

牧云@^-^@ 提交于 2020-01-04 05:33:27
问题 I'm using DOMDocument and SimpleXMLElement to create a formatted XML file. While this all works, the resulting file is saved as ASCII, not as UTF-8. I can't find an answer as to how to change that. The XML is created as so: $XMLNS = "http://www.sitemaps.org/schemas/sitemap/0.9"; $rootNode = new \SimpleXMLElement("<?xml version='1.0' encoding='UTF-8'?><urlset></urlset>"); $rootNode->addAttribute('xmlns', $XMLNS); $url = $rootNode->addChild('url'); $url->addChild('loc', "Somewhere over the

Classic ASP's Request.Form is dropping an 8-bit character — is there a simple way to prevent this?

≡放荡痞女 提交于 2020-01-04 04:21:26
问题 A client of mine is using a Classic ASP script to process a form from a third-party payment processor (this is the last step in a credit-card-transaction sequence that starts at the client's website, goes to the third-party site, and then returns to the client's site). The client is in Austria and when one of the fields includes an 8-bit character (e.g., when the field value is Österreich), the Ö is simply dropped when I retrieve the value of the field in the standard way; e.g.: fieldval =

How to convert text to unicode in Rails?

亡梦爱人 提交于 2020-01-04 04:17:14
问题 In my database, I have the following entry id | name | info 1 John Smith Çö ¿¬¼ As you can tell, the info column displays wrong -- it's actually Korean, though. In Chrome, when I switch the browser encoding from UTF-8 to Korean ('euc-kr', I think), I actually manage to view the text as such: id | name | info 1 John Smith 횉철 쩔짭쩌 I then manually copy the text into the info in the database and save, and now I can view it in UTF-8, without switching my browser's encoding. Awesome. Now I'd like to

CSV utf8 import with phpmyadmin

女生的网名这么多〃 提交于 2020-01-04 04:08:29
问题 I am trying to import a dataset with korean characters in, saved as unicode encoding using CSV LOAD DATA even when I set the input character set to utf8 the korean get's mangled the encoding for that column is of course utf8 sample record (tab delimited): 79 읽다 read NULL what goes into MYSQL: 79 ì½ë‹¤ read NULL 回答1: load data supports character set clause load data local infile 'filename.txt' into table test.unicode CHARACTER SET utf8 Use it from the command line if phpmyadmin ignores it. 回答2

notepad ++ shows ucs-2LE while ubuntu FILE [file] shows UTF-16LE, I am confused?

☆樱花仙子☆ 提交于 2020-01-04 04:08:10
问题 I am trying to convert the file generated from a mssql to utf-8. When I open the output of he mssql using notepad++ in windows server 2003 recognises the file as UCS-2LE I copied the file to a Ubuntu machine, using file [file] it shows that the encoding is UTF-16LE . Really confused, there must be some difference in encoding, as the names are different. But why do I see this in the same file. Its a .csv file generated from the mssql query. 回答1: For the most part, UTF-16 and UCS-2 are the same

jQuery: Set encoding for json response to utf8

只愿长相守 提交于 2020-01-04 03:59:10
问题 I'm getting my response for jQuery in json. The logic works fine, but I can't get him to proper encode the data (like üäö). I've searched and found this question on SO, which suggested to change the getJSON to a normal AJAX call. I've done that, and added the setContentType option, but still, I'm getting weird signs, as soon as an äüö appears. Any ideas on how to solve that? $(function() { $("#cnAntragsteller").autocomplete({ source: function(request, response) { $.ajax({ url: "http:/

Why do i have to use set_charset(“utf8”) even though everything is utf-8 encoded? (MySQLi-PHP)

非 Y 不嫁゛ 提交于 2020-01-04 01:53:22
问题 My table's collation is utf8_general_ci. My pages are encoded with UTF-8 (without BOM). Within my pages, my Equiv meta tag sets character set to utf8 My data has Turkish characters in it. When i output them, it's not showing them as it should be but when i do $db->set_charset("utf8"); , it works. Why do i have to use $db->set_charset("utf8"); even though everything is utf-8 encoded? 回答1: The data is stored as UTF-8 in MySQL, but the PHP's client connection collation is not. Which is why you

Converting “wrong” MySQL encoding from old server to correct UTF-8 on new server

回眸只為那壹抹淺笑 提交于 2020-01-04 01:53:07
问题 I set up a web project on a web server with apparently wrong encoding. But somehow (I really don't know why), we figured how we had to deal with it and the encoding worked for us. But now we moved the data to a new server with a correctly set up UTF8 database and surprise, the encoding is wrong. How can we "correct" the data, is there any best practice? Example old server: http://www.orat.io/stmt/200 new server: http://www.firefile.net/stmt/200 Thanks a lot! 回答1: This actually happens in

Python: ascii codec can't encode en-dash

China☆狼群 提交于 2020-01-03 18:55:31
问题 I'm trying to print a poem from the Poetry Foundation's daily poem RSS feed with a thermal printer that supports an encoding of CP437. This means I need to translate some characters; in this case an en-dash to a hyphen. But python won't even encode the en dash to begin with. When I try to decode the string and replace the en-dash with a hyphen I get the following error: Traceback (most recent call last): File "pftest.py", line 46, in <module> str = str.decode('utf-8') File "/usr/lib/python2.7