utf8-decode

Python encoded utf-8 string \xc4\x91 in Java

匆匆过客 提交于 2021-02-08 13:46:14
问题 How to get proper Java string from Python created string 'Oslobo\xc4\x91enja'? How to decode it? I've tryed I think everything, looked everywhere, I've been stuck for 2 days with this problem. Please help! Here is the Python's web service method that returns JSON from which Java client with Google Gson parses it. def list_of_suggestions(entry): input = entry.encode('utf-8') """Returns list of suggestions from auto-complete search""" json_result = { 'suggestions': [] } resp = urllib2.urlopen(

Java UTF-8 encoding not set to URLConnection

爱⌒轻易说出口 提交于 2020-01-11 00:07:43
问题 I'm trying to retrieve data from http://api.freebase.com/api/trans/raw/m/0h47 As you can see in text there are sings like this: /ælˈdʒɪəriə/ . When I try to get source from the page I get text with sings like ú etc. So far I've tried with the following code: urlConnection.setRequestProperty("Accept-Charset", "UTF-8"); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); What am I doing wrong? My entire code: URL url = null; URLConnection urlConn

Decode UTF-8 with Javascript

不问归期 提交于 2020-01-08 15:50:40
问题 I have Javascript in an XHTML web page that is passing UTF-8 encoded strings. It needs to continue to pass the UTF-8 version, as well as decode it. How is it possible to decode a UTF-8 string for display? <script type="text/javascript"> // <![CDATA[ function updateUser(usernameSent){ var usernameReceived = usernameSent; // Current value: Größe var usernameDecoded = usernameReceived; // Decode to: Größe var html2id = ''; html2id += 'Encoded: ' + usernameReceived + '<br />Decoded: ' +

Decode UTF-8 with Javascript

☆樱花仙子☆ 提交于 2020-01-08 15:50:03
问题 I have Javascript in an XHTML web page that is passing UTF-8 encoded strings. It needs to continue to pass the UTF-8 version, as well as decode it. How is it possible to decode a UTF-8 string for display? <script type="text/javascript"> // <![CDATA[ function updateUser(usernameSent){ var usernameReceived = usernameSent; // Current value: Größe var usernameDecoded = usernameReceived; // Decode to: Größe var html2id = ''; html2id += 'Encoded: ' + usernameReceived + '<br />Decoded: ' +

MySQL convert charset issue

↘锁芯ラ 提交于 2020-01-04 10:58:11
问题 I have an application which runs on PHP 5 and accesses and stores a MySQL database using the mysqli extension. The database contains numerous tables with the encoding UTF-8 (collation utf8_swedish_ci ). Unfortunately, it seems that the mysqli connection was configured to encode everything using ISO-8859-1,which means that I've got UTF-8 tables containing latin1 data. I am trying to repair this now, by shifting over everything to UTF-8 (as it should be!) Is there a built-in way of handling

Non English (Hebrew) output in RStudio console

扶醉桌前 提交于 2020-01-04 00:40:11
问题 The following test works fine on my laptop, but produces an error on my HP EliteOne 800 running Windows 10 H <- "שלום" H In the machine with the problem I get [1] "ùìåí" I tested several encoding, such as Encoding(H) <- "ISO-8859-1" which gives the same output, and Encoding(H)<-"UTF-8" H that produces [1] "\xf9\xec\xe5\xed" Below is the response to sessionInfo() R version 3.2.2 (2015-08-14) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 8 x64 (build 9200) locale: [1] LC

Python: ascii codec can't encode en-dash

China☆狼群 提交于 2020-01-03 18:55:31
问题 I'm trying to print a poem from the Poetry Foundation's daily poem RSS feed with a thermal printer that supports an encoding of CP437. This means I need to translate some characters; in this case an en-dash to a hyphen. But python won't even encode the en dash to begin with. When I try to decode the string and replace the en-dash with a hyphen I get the following error: Traceback (most recent call last): File "pftest.py", line 46, in <module> str = str.decode('utf-8') File "/usr/lib/python2.7

How do I capture utf-8 decode errors in node.js?

♀尐吖头ヾ 提交于 2019-12-29 06:41:14
问题 I just discovered that Node (tested: v0.8.23, current git: v0.11.3-pre) ignores any decoding errors in its Buffer handling, silently replacing any non-utf8 characters with '\ufffd' (the Unicode REPLACEMENT CHARACTER) instead of throwing an exception about the non-utf8 input. As a consequence, fs.readFile , process.stdin.setEncoding and friends mask a large class of bad input errors for you. Example which doesn't fail but really ought to: > notValidUTF8 = new Buffer([ 128 ], 'binary') <Buffer

spyder unicode decode error in startup

不羁的心 提交于 2019-12-23 03:29:20
问题 I was using spyder-ide while parsing a tumblr page with the permission of the author, and at some point everything just crashed. Even my linux system had freezed. Well, to cut to the chase now I can not start spyder, it gives me the following error after I had written spyder to my terminal: Traceback (most recent call last): File "/home/dk/anaconda3/bin/spyder", line 2, in <module> from spyderlib import start_app File "/home/dk/anaconda3/lib/python3.5/site-packages/spyderlib/start_app.py",

Ruby: Checking for East Asian Width (Unicode)

感情迁移 提交于 2019-12-22 05:27:23
问题 Using Ruby, I have to output strings in an columnar format to the terminal. Something like this: | row 1 | a string here | etc | row 2 | another string | etc I can do this fine with Latin UTF8 characters using String#ljust and %s. But a problem arises when the characters are Korean, Chinese, etc. The columns simply won't align when there are rows of English interspersed with rows containing Korean, etc. How can I get column alignment here? Is there a way to output Asian characters in the