utf-8

Python insert UTF8 string into SQLite

浪尽此生 提交于 2020-01-02 08:33:53
问题 I know there are similar questions, but the answers are distinct and kind of confusing. I have this string: titulo = "Así Habló Zaratustra (Cómic)" When I try to insert it to the SQLite database I get the error: sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. I've tried a couple of things without

Content-Type with charset only

喜欢而已 提交于 2020-01-02 08:16:48
问题 I came across this interesting header: Content-Type: charset=utf-8 Set HTTP header to UTF-8 using PHP The answerer says that this syntax is defined by RFC 2616, but I am not seeing it in the provided link. Is this valid syntax, and if so where specifically is this defined? 回答1: The production in RFC 2616 for the Content-Type header is this: Content-Type = "Content-Type" ":" media-type And the media-type production is this: media-type = type "/" subtype *( ";" parameter ) type = token subtype

How to normalize unicode encoding for iso-8859-15 conversion in python?

只谈情不闲聊 提交于 2020-01-02 08:03:10
问题 I want to convert unicode string into iso-8859-15. These strings include the u"\u2019" (RIGHT SINGLE QUOTATION MARK see http://www.fileformat.info/info/unicode/char/2019/index.htm) character which is not part of the iso-8859-15 characters set. In Python, how to normalize the unicode characters in order to match the iso-8859-15 encoding? I have looked at the unicodedata module without success. I manage to do the job with s.replace(u"\u2019", "'").encode('iso-8859-15') but I would like to find

JSF 2.0 request.getParameter return a string with wrong encoding

戏子无情 提交于 2020-01-02 07:58:49
问题 I'm writing an application in JSF 2.0 which supports many languages, among them ones with special characters. I use String value = request.getParameter("name") and POST method, the page encoding is set to UTF-8 and the app is deployed on apache tomcat 6 which has the connector set correctly to utf-8 in a server.xml file: <Connector URIEncoding="utf-8" connectionTimeout="20000" port="8088" protocol="HTTP/1.1" redirectPort="8443"/> Yes I get strange results like ä for example in place of

Utf-8 characters displayed as ISO-8859-1

自古美人都是妖i 提交于 2020-01-02 06:35:10
问题 I've got an issue with inserting/reading utf8 content from a db. All verifications I'm doing seem to point to the fact that the content in my DB should be utf8 encoded, however it seems to be latin encoded. The data are initially imported from a PHP script from the CLI. Configuration: Zend Framework Version: 1.10.5 mysql-server-5.0: 5.0.51a-3ubuntu5.7 php5-mysql: 5.2.4-2ubuntu5.10 apache2: 2.2.8-1ubuntu0.16 libapache2-mod-php5: 5.2.4-2ubuntu5.10 Vertifications: -mysql: mysql> SHOW VARIABLES

Re-encode url from utf-8 encoded to iso-8859-1 encoded

大憨熊 提交于 2020-01-02 06:01:11
问题 I have file:// links with non-english characters which are UrlEncoded in UTF-8. For these links to work in a browser I have to re-encode them. file://development/H%C3%A5ndplukket.doc becomes file://development/H%e5ndplukket.doc I have the following code which works: public string ReEncodeUrl(string url) { Encoding enc = Encoding.GetEncoding("iso-8859-1"); string[] parts = url.Split('/'); for (int i = 1; i < parts.Length; i++) { parts[i] = HttpUtility.UrlDecode(parts[i]); // Decode to string

Re-encode url from utf-8 encoded to iso-8859-1 encoded

一世执手 提交于 2020-01-02 06:00:04
问题 I have file:// links with non-english characters which are UrlEncoded in UTF-8. For these links to work in a browser I have to re-encode them. file://development/H%C3%A5ndplukket.doc becomes file://development/H%e5ndplukket.doc I have the following code which works: public string ReEncodeUrl(string url) { Encoding enc = Encoding.GetEncoding("iso-8859-1"); string[] parts = url.Split('/'); for (int i = 1; i < parts.Length; i++) { parts[i] = HttpUtility.UrlDecode(parts[i]); // Decode to string

UnicodeEncodeError [Python3/Gunicorn/Nginx/Django]

我怕爱的太早我们不能终老 提交于 2020-01-02 05:41:43
问题 Solved This error happened when I follow the instruction in here. I set Unit file. I understood that LAN env valuable doens't transfer properly and it used default ascii. You can fix this problem with adding one line in unit file. It was a really long journey to find out.... [service] Environment="LANG=en_US.UTF-8" I didn't have any problem when I set my environment with mod_wsgi and Apache2. I just had to add " export LANG='en_US.UTF-8' export LC_ALL='en_US.UTF-8' " in /etc/apache2/envars

C++: Qt 5.3 fails to display UTF-8 character

江枫思渺然 提交于 2020-01-02 05:39:07
问题 I am trying to display a unicode character (Euro sign) on a button using Qt and C++ in Visual Studio 2013. I tried the following code: _rotateLeftButton->setText("\u20AC"); and _rotateLeftButton->setText("€"); and _rotateLeftButton->setText(QString::fromUtf8("\u20AC")); and _rotateLeftButton->setText(QString::fromUtf8("€")); However, all of those lines result in the following: All my code files are UTF-8 encoded, except for the moc files (.cxx). For whichever reason the moc executable does

How can I print a euro (€) symbol in Python?

喜欢而已 提交于 2020-01-02 05:04:58
问题 I'm teaching myself Python using the command-line interpreter (v3.5 for Windows). All I want to do is output some text that includes the euro (€) symbol which I understand to be code 80h (128 dec). #! # -*- coding: utf-8 -*- mytext = 'Please pay \x8035.' print(mytext) It falls over on the last line: UnicodeEncodeError: 'charmap' codec can't encode character '\x80' in position 11: character maps to <undefined> I've done lots of googling (re encodings etc) and I've a rough idea why the print