encoding

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,

Chinese character encoding error with BeautifulSoup in Python?

心不动则不痛 提交于 2020-01-04 05:23:07
问题 I'd like to use BeatifulSoup to get the data in a table from a website, but it couldn't grab the Chinese character correctly. This is my code: #!/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 from bs4 import BeautifulSoup html=urllib2.urlopen("http://www.515fa.com/che_1978.html").read() soup=BeautifulSoup(html,from_encoding="UTF-8") print soup.prettify() And the Chinese characters are displayed like this: <td align="center" bgcolor="#FFFFFF" u1:str="" width="173"> ćé¸</td> <td

Display Emoji character in JTable

懵懂的女人 提交于 2020-01-04 04:37:07
问题 I want to display loudspeaker character in a JTable : @Override public Object getValueAt(int row, int col) { switch (col) { [...] case 2: String symbol = "\uD83D\uDD0A"; return "State " + symbol; default: return ""; } } Unfortunaly i just see an square box. I'm not sure if i have to set an specific Font supporting this character or to apply an other encoding. For Googlers looking for a solution: I implemented a CustomRenderer for the JTable like @trashgod sugested. Examples are available here

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:/

Curly quotation marks vs Square quotation marks, what gives?

天涯浪子 提交于 2020-01-04 03:53:26
问题 An interesting problem that no doubt someone here has come across before. I'm reading a CSV file that contains some values wrapped in quotes, I came across a problem today were my app couldn't read the file as the value was wrapped in cury quotation marks and not square quotation marks. Is this an encoding problem? I simply replaced the quotes replacing curly quote with ". Can someone explain why this happens and what I can do about it? I'm using C# 回答1: I suspect the data was copied and

Decrypt TripleDES “Bad Data”

我只是一个虾纸丫 提交于 2020-01-04 03:49:07
问题 I'm new to encryption/decryption. I'm trying to decrypt an input string that is encrypted and comes out to 44 characters. This is what I have so far but I keep getting "bad data" when it attempts to execute the "TransformFinalBlock" function. public static String Decrypt(String input) { try{ byte[] inputArray = Convert.FromBase64String(input); TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.KeySize = 128; tripleDES.Key = UTF8Encoding.UTF8.GetBytes(

Page with UTF-8 encoding sends data to MySQL with UTF-8 encoding but entry is scrambled

我只是一个虾纸丫 提交于 2020-01-04 03:14:27
问题 I realize there's a dozen similar questions, but none of the solutions suggested there work in this case. I have a PHP variable on a page, initialized as: $hometeam="Крылья Советов"; //Cyrrilic string When I print it out on the page, it prints out correctly. So echo $hometeam displays the string Крылья Советов, as it should. The content meta tag in the header is set as follows: <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> And, at the very beginning of the page, I have

How to serve static file with a hebrew name in python bottle?

五迷三道 提交于 2020-01-04 02:07:12
问题 I receive a request from the client to download some file from the server. The filename is in Hebrew. @bottle.get("/download/<folder_name>/<file_name>") def download(folder_name, file_name): file_name = file_name.decode('utf-8') folder_name = folder_name.decode('utf-8') if os.path.exists(os.path.join(folder_name, file_name)): return bottle.static_file(file_name, root=folder_name, download=True) The last line fails : return bottle.static_file(file_name, root=folder_name, download=True) I get

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