utf-8

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! =)

Read file from multiple encoding in c# [duplicate]

余生颓废 提交于 2021-01-28 21:31:45
问题 This question already has answers here : How can I detect the encoding/codepage of a text file (20 answers) How to use ReadAllText when file encoding unknown (2 answers) Closed 5 years ago . ENV: C#, VStudio 2013, 4.5 Framework, Winforms, nHapi 2.3 dll I really need help on this. I have tried soo many things and did alot of research with my best friend google ;-). But no luck. I'm building a HL7 sender tools and I'm reading files from a folder. My files come from multiple sources and I found

Using Swift, how do you re-encode then decode a String like this short script in Python?

穿精又带淫゛_ 提交于 2021-01-28 19:36:34
问题 XKCD has some issues with their API and weird encoding issues. Minor encoding issue with xkcd alt texts in chat The solution (in Python) is to encode it as latin1 then decode as utf8, but how do I do this in Swift? Test string: "Be careful\u00e2\u0080\u0094it's breeding season" Expected output: Be careful—it's breeding season Python (from above link): import json a = '''"Be careful\u00e2\u0080\u0094it's breeding season"''' print(json.loads(a).encode('latin1').decode('utf8')) How is this done

MySQL warning: Incorrect string value: '\x96

会有一股神秘感。 提交于 2021-01-28 18:35:23
问题 I'm trying to import a CVS file where I get this warning: 1366 Incorrect string value: '\x96 PART...' for column I read somewhere that this is about the 4-bit utf8 characters. But changing the collation of the table and column into utf8mb4 didn't work either. 回答1: The hex 96 is presumably the latin1 encoding for an en-dash ( – ). But you have specified that the CSV file is utf8-encoded (or utf8mb4), this character is incomprehensible to utf8. Plan A: Change the file. (This is probably not

MySQL warning: Incorrect string value: '\x96

北城以北 提交于 2021-01-28 18:31:23
问题 I'm trying to import a CVS file where I get this warning: 1366 Incorrect string value: '\x96 PART...' for column I read somewhere that this is about the 4-bit utf8 characters. But changing the collation of the table and column into utf8mb4 didn't work either. 回答1: The hex 96 is presumably the latin1 encoding for an en-dash ( – ). But you have specified that the CSV file is utf8-encoded (or utf8mb4), this character is incomprehensible to utf8. Plan A: Change the file. (This is probably not

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,

Converting character encoding within c++

瘦欲@ 提交于 2021-01-28 12:34:30
问题 I have a website which allows users to input usernames. The problem here is that the code in c++ assumes the browser encoding is Western Europe and converts the string received from the username text box into unicode to compare with string stored within the databasse. with the right browser encoding set the character úser is recieved as %FAser and coverted properly to úser within the program however with the browser settings set to UTF-8 the string is recieved as %C3%BAser and then converted

Converting character encoding within c++

为君一笑 提交于 2021-01-28 12:32:13
问题 I have a website which allows users to input usernames. The problem here is that the code in c++ assumes the browser encoding is Western Europe and converts the string received from the username text box into unicode to compare with string stored within the databasse. with the right browser encoding set the character úser is recieved as %FAser and coverted properly to úser within the program however with the browser settings set to UTF-8 the string is recieved as %C3%BAser and then converted

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,