utf-8

R, Windows and foreign language characters

让人想犯罪 __ 提交于 2020-01-01 18:59:28
问题 This has been a longstanding problem with R: it can read non-latin characters on Unix, but I cannot read them on Windows . I've reproduced this program on several English-edition Windows machines over the years. I've tried changing the localisation settings in Windows and numerous other to no effect. Has anyone actually been able to read a foreign text file on Windows? I think being able to read/write/display unicode is a pretty nifty feature for a program. Environment: > Sys.getlocale() [1]

Classic ASP - how to save data to CSV file with UTF-8

对着背影说爱祢 提交于 2020-01-01 18:20:52
问题 I have the following code: output = ... (some comma-separated data) Response.Clear 'Response.ChartSet = "UTF-8" 'Response.CodePage = 65001 Response.ContentType = "text/csv" Response.AddHeader "Content-Disposition", "filename=myfile.csv;" Response.Write(output) Response.End Now, everything is working just fine with having the data itself and generating a virtual CSV file for direct download, but if I have a non-ascii data in one or more of the fields (columns), I don't get it in UTF-8 in the

Write to file with xp_cmdshell in UTF-8

拜拜、爱过 提交于 2020-01-01 17:27:36
问题 I am creating files with xp_cmdshell like this: SELECT @command = 'echo ' + @fileContent + ' > e:\out\' + @fileName + '.csv' exec master.dbo.xp_cmdshell 'mkdir "e:\out\"' exec master..xp_cmdshell @command The problem is that the file contents is not in UTF-8 and so some special characters are wrong. Can i create the file in UTF-8 encoding? 回答1: You can use the SQLCMD instead the old tecnique as DOS outupt redirect sqlcmd -S ServerName -d DataBaseName -E -o "CSV File Path & Location" -Q "Your

C++ iterate utf-8 string with mixed length of characters

余生长醉 提交于 2020-01-01 17:26:30
问题 I need to loop over a utf-8 string and get each character of the string. There might be different types of characters in the string, e.g. numbers with the length of one byte, Chinese characters with the length of three bytes, etc. I looked at this post and it can do 80% of the job, except that when the string has 3-byte chinese characters before 1-byte numbers, it will see the numbers also as having 3 bytes and print the numbers as 1** where * is gibberish. To give an example, if the string

How convert PHP value from windows-1257 to UTF-8

北战南征 提交于 2020-01-01 14:45:50
问题 How convert PHP value from windows-1257 to UTF-8? I tried many ways, but they was not successful. I have lttu�s and I wanna convert this to littūs. utf8_encode(); iconv_set_encoding("windows-1257", "UTF-8"); mb_convert_encoding() Doesn't work. :( Can anybody help me? 回答1: $encoded= iconv ("CP1257","UTF-8", $string) 回答2: Use mb_convert_encoding($data, 'UTF-8', 'ISO-8859-13'); 回答3: Have you checked that the page you are using to display the converted string has the Encoding and CodePage set

Does std::wstring support UTF-16 and UTF-32 on Windows?

旧城冷巷雨未停 提交于 2020-01-01 12:16:13
问题 I'm learning about Unicode and have a few questions that I'm hoping to get answered. 1) I've read that on Linux, a std::wstring is 4-bytes, while on Windows, it's 2-bytes. Does this mean that Linux internal support is UTF-32 while Windows it is UTF-16 ? 2) Is the use of std::wstring very similar to the std::string interface? 3) Does VC++ offer support for using a 4-byte std::wstring? 4) Do you have to change compiler options if you use std::wstring? As a sidenote, I came across a string

Encoding of AVMetadataItem

末鹿安然 提交于 2020-01-01 12:11:21
问题 I have a AVMetadataItem which has fields encoded in CP1251 (Cyrillic). After reading item.stringValue I get garbage - incorrectly encoded string. I've tried converting that string to raw UTF8 and then creating a new string using the CP1251 encoding - no luck, result is nil. Tried taking the item.dataValue - no dice, it contains a raw list data (starting with bplist...). Any ideas are very appreciated. Thanks in advance. 回答1: Swift 2.0 solution: let origTitleMeta: NSData = (<AVMetadataItem>

Ruby Iconv works with irb and ruby debugger but not in a unit test

左心房为你撑大大i 提交于 2020-01-01 12:01:12
问题 I'm running Ruby 1.8.7 with Rails 2.3.5 on Ubuntu 10.04 64-bit. I've written a method that should take a string like this, "École À la Découverte" and output a file-system name like this "ecole_a_la_decouverte" : (Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv "École À la Découverte").downcase.split.join('_') When I test this line in my code, the test always fails saying that "cole_la_dcouverte" is unequal to "ecole_a_la_decouverte" . The odd thing is that if I insert a debugger line and use

NodeJS decodeURIComponent not working properly

牧云@^-^@ 提交于 2020-01-01 11:58:50
问题 When I tryed to decode the string below in nodeJS using decodeURLCompnent: var decoded = decodeURI('Ulysses%20Guimar%C3%A3es%20-%20lado%20par'); console.log(decoded); I got Ulysses Guimarães - lado par Instead of Avenida Ulysses Guimarães - lado par But when I use the same code on the client side (browser) I can get the right char 'ã'. Is there a way to convert from ã to ã in a Node script? 回答1: I cannot reproduce it in 0.10 or 0.11 versions of node. You can convert first to second using

C++ Error “failure: locale::facet::_S_create_c_locale name not valid” when running program from command line

帅比萌擦擦* 提交于 2020-01-01 11:52:08
问题 I seem to have a problem with locales in C++. When I run my programm from within Eclipse, it all works fine. However, when I try to run from the command line, I keep getting this error: failure: locale::facet::_S_create_c_locale name not valid This is the code that triggers the error: // Set up UTF8 file stream string fileName = "./sz.txt"; wifstream inFileStream; try { setlocale(LC_ALL, ""); inFileStream.open(fileName.c_str()); inFileStream.imbue(locale("")); if(!inFileStream) { return EXIT