unicode

Django SQL Logging as UTF-8 : avoiding UnicodeDecodeError while settings.DEBUG=True

牧云@^-^@ 提交于 2021-01-29 03:15:14
问题 For a long time, I've had to struggle with a "UnicodeDecodeError:ascii codec can't decode..." error while save()-ing a model, until I "accidentally" set settings.DEBUG=False. I realized then that the Unicode exception was not from my data nor from my code, but from Django's SQL logging, which is apparently in ascii. Question is, is there an easy way to convert the logging from ascii to utf-8, so that I can still avail of the logging feature without dealing with the exception? Many thanks! =)

How to convert Unicode string to a TCHAR system?

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 02:55:46
问题 I have a python (3.6) code that should pass a Unicode string to an Unreal Engine project. The Unreal Engine displays text in TEXT format which I'm not wrong is an array of Win-Api's TCHARs. I saw that on my platform the TCHAR is 2 bytes. Here is how I encode the string on the python side: by = bytes(st, 'utf-8') I tried encoding and passing the string "Hello" . The unreal got the data ['H', 'e', 'l', 'l', 'o'] (each char 1 byte), and printed "效汬o" (it treats the "He" and "ll" as a single

ASCII codec can't encode character u'\u2013'

 ̄綄美尐妖づ 提交于 2021-01-28 20:20:55
问题 I have a little Python code in Q_GIS which opens objects. The problem I have is that in the directory there is a character (underscore like character) that can not be encoded. The error is: Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 10: ordinal not in range(128) My little code is: from os import startfile; proj = QgsProject.instance(); UriFile = str(proj.fileName()); img = '[% "pad" %]'; Path = str(os

Writing emoji to XML file in JAVA

笑着哭i 提交于 2021-01-28 18:49:24
问题 Short question: Given a String str = "😭"; output an XML file containing <tag>😭</tag> instead of <tag>😭</tag> I am trying to create an XML file in JAVA that may contain normal text or emoji within a tag. The XML file is in UTF-8 encoding, so that when opened up in Notepad++, you can see normal text as well as emoji within a tag. While testing my code, somehow the emoji got translated as &#xxxxxx;. Sample code: String str = "😭"; Document document = DocumentBuilderFactory.newInstance()

MySQL 5.6 create view with unicode character set

不打扰是莪最后的温柔 提交于 2021-01-28 14:04:19
问题 MySQL 5.6. I can't get a string constant within a view to populate correctly against a database with default UCS2 character set. Works fine on 5.7. I've created a minimally reproducible example, below. DROP SCHEMA IF EXISTS test3; CREATE SCHEMA test3 CHARACTER SET ucs2; CONNECT test3; CREATE TABLE testtable ( testname VARCHAR(15) ); INSERT INTO testTable( testname ) VALUES ('foo'); INSERT INTO testTable( testname ) VALUES ('bar'); CREATE OR REPLACE VIEW testview AS SELECT * FROM testtable

MySQL 5.6 create view with unicode character set

不想你离开。 提交于 2021-01-28 14:00:38
问题 MySQL 5.6. I can't get a string constant within a view to populate correctly against a database with default UCS2 character set. Works fine on 5.7. I've created a minimally reproducible example, below. DROP SCHEMA IF EXISTS test3; CREATE SCHEMA test3 CHARACTER SET ucs2; CONNECT test3; CREATE TABLE testtable ( testname VARCHAR(15) ); INSERT INTO testTable( testname ) VALUES ('foo'); INSERT INTO testTable( testname ) VALUES ('bar'); CREATE OR REPLACE VIEW testview AS SELECT * FROM testtable

Convert file from Cp1252 to utf -8 java

放肆的年华 提交于 2021-01-28 12:55:44
问题 User uploads file with the character encoding : Cp1252 Since my mysql table columns Collation as utf8_bin, I try to convert the file to utf-8 before putting the data into table using LOAD DATA INFILE command. Java source code: OutputStream output = new FileOutputStream(destpath); InputStream input = new FileInputStream(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(input, "windows-1252")); BufferedWriter writ = new BufferedWriter(new OutputStreamWriter(output,

Reading proper unicode characters into a ReadStream in node.js

孤者浪人 提交于 2021-01-28 11:47:49
问题 Sometimes strange things happen in the world of coding, and I have no explanation at all. :) A text file I have contains the following lines: en …π 1 1 en Œ® 1 1 en Œ© 1 1 en –° 1 1 en —† 1 1 en “§ 1 1 en ◊° 2 2 en ·∏§anƒ´f 1 1 en ·π_ 1 1 en ˝mage:whiteshark-tgoss1.jpg 4 4 en ˝stanbul 114 114 My code is as follows: var fileReadStream = fs.createReadStream(fileName, {encoding: 'utf8'}); fileReadStream.on('data', function(data){ //do something with the data }); When I look at the data element,

Reading proper unicode characters into a ReadStream in node.js

孤街醉人 提交于 2021-01-28 11:39:01
问题 Sometimes strange things happen in the world of coding, and I have no explanation at all. :) A text file I have contains the following lines: en …π 1 1 en Œ® 1 1 en Œ© 1 1 en –° 1 1 en —† 1 1 en “§ 1 1 en ◊° 2 2 en ·∏§anƒ´f 1 1 en ·π_ 1 1 en ˝mage:whiteshark-tgoss1.jpg 4 4 en ˝stanbul 114 114 My code is as follows: var fileReadStream = fs.createReadStream(fileName, {encoding: 'utf8'}); fileReadStream.on('data', function(data){ //do something with the data }); When I look at the data element,

Unable to extract Unicode symbols from C++ std::string

偶尔善良 提交于 2021-01-28 11:22:06
问题 I am looking to read a C++ std::string, then passing that std::string to a function which would analyse it, then extract Unicode symbols & simple ASCII symbols from it. I searched many tutorials online, but all of them mentioned that standard C++ does not fully support Unicode format. Many of them mentioned to use ICU C++ . This is my C++ program for understanding the very basic of above functionalities. It reads the raw string, converts to ICU Unicode String & prints that: #include <iostream