Python write to json file gives UnicodeDecodeError

I have a list of dictionaries final and when I try to export it to json, I get the following error. In creating the final, I have used manipulation of some csv files that contain non-ascii characters. All csv files are UTF-8 type csv. dirname = os.p...
more »

2017-10-20 10:10 (0) Answers

UTF-8 in Android compared to definition of UTF-8

i got a question to UTF-8 in Android. I Need to store a String into a Byte[] in UTF-8 Format. So far so good. Here is my code where the user type into a editText and this should be stored into a Byte[] in UTF-8 Format: idString = editId.getText()....
more »

2017-10-19 14:10 (1) Answers

Django issue : UnicodeEncodeError

I'm getting this common error in my code : Exception Type: UnicodeEncodeError Exception Value:'ascii' codec can't encode character u'\xe9' in position 6: ordinal not in range(128) Why ? Because I'm handling firstnames with french accents. This is...
more »

2017-10-03 12:10 (2) Answers fails to read plain ASCII file

I have a plain ASCII file. When I try to open it with, "utf-8"), I am unable to read single characters. ASCII is a subset of UTF-8, so why can't codecs open such a file in UTF-8 mode? # import codecs f ="test.p...
more »

2017-09-27 02:09 (1) Answers

python encoding ' (quotation) in xml file

I have a xml file for which the encoding information is not specified. I am trying to read it and write the file in another location using the below method import xml.etree.ElementTree as ET import pandas as pd from lxml import etree,html from lxml....
more »

2017-09-12 10:09 (2) Answers

Perl utf8 binmode unexpected results

Why does binmode as raw produce the umlaut? Could any elaboration be given regarding how 'Zurich' String is stored internally in Perl? Just a little lost. use strict; use warnings; my $filename = "result-test-encoding-raw.xml"; open(my $fh,'>', ...
more »

2017-09-05 22:09 (2) Answers

Is this a valid UTF8 character in this xml file?

I have received some XML from an upstream data source. I'm not sure if these weird characters are valid UTF8 -or- the upstream source has messed things up. i.e. Bad data in => bad data out. I'm guessing the following is what was passed down: Val...
more »

2017-09-05 08:09 (1) Answers

Encoding of special properties in Eclipse

I have an application which uses swedish language in some java and jsp pages. Swedish words are described in file and those names will be used in the application. Application Screen: Words which are defined in the propert...
more »

2017-09-03 22:09 (4) Answers

Ascii code of music clef in Safari on iphone

I can't figure out how to display ascii code &#119070 (music clef) on my web page in safari on iphone. I left out ; at the end on purpose, so you can see what the code is. It works in Safari on Mac and in all other browsers. All the other codes ...
more »

2017-08-15 20:08 (1) Answers

How to check if a UTF-8 string starts with an 'a'

I have a UTF-8 string given as a null-terminated const char*. I would like to know if the first letter of this string is an a by itself. The following code bool f(const char* s) { return s[0] == 'a'; } is wrong, as the first letter (grapheme clu...
more »

2017-06-19 21:06 (4) Answers

SimpleXML changing file encoding

I am trying to write a function which could read an existing XML file and create a new one with all the data from the first one, but in a different encoding. As far I understand it, SimpleXML saves the file in UTF-8 encoding. My original XML file is ...
more »

2017-06-07 13:06 (2) Answers

Send arrow character to iPhone with SMS

I'm trying to send an up arrow to an iPhone with SMS using VBA and a CDO mail object. 'tried as Unicode: subj = ChrW(8593) & " Up " & ChrW(8593) 'also as HTML special character: subj = "↑ Up ↑" These result in either a ...
more »

2017-05-12 02:05 (1) Answers

XML to CSV using XSLT - preserve polish letters

I'm converting XML to CSV using XSLT. My output line in XSLT is: <xsl:output method="text" encoding="UTF-8" /> There is a lot of polish letters in XML, that's the problem. When I transform the XML from Notepad++ using XML tools plugin, the ou...
more »

2017-05-05 15:05 (1) Answers

Java - Fastest way to check the size of String

I have the following code inside a loop statement. In the loop, strings are appended to sb(StringBuilder) and checked whether the size of sb has reached 5MB. if (sb.toString().getBytes("UTF-8").length >= 5242880) { // Do something } This wo...
more »

2017-04-24 13:04 (4) Answers

Zend: UTF-8 encoding

My job is to migrate our current website to production. (I'm not the developer of the zend app). It's a french app, so we use a lot of french characters like "é" Our database collapse is utf8_bin (all). If I use a form for uploading data (for exam...
more »

2017-04-13 03:04 (0) Answers