execute query = query.encode(charset) UnicodeEncodeError: 'latin-1'Here it complains that it deals with the character U+2013, which
codec can't encode character u'\u2013' in position 52: ordinal not in
range(256)
is "EN DASH"; it complains that the encoding called "latin-1" does
not support that character.
That is a fact - Latin-1 does not support EN DASH.
When I type 'print chr(150)' into a python command line window I getThat's because your console uses the code page 437:
a LATIN SMALL LETTER U WITH CIRCUMFLEX
(http://www.fileformat.info/info/unic...0fb/index.htm),
pychr(150).decode("cp437")
u'\xfb'
pyunicodedata.name(_)
'LATIN SMALL LETTER U WITH CIRCUMFLEX'
Code page 437, on your system, is the "OEM code page".
but when I do so into a IDLE window I get a hypen (chr(45).That's because IDLE uses the "ANSI code page" of your system,
which is windows code page 1252.
pychr(150).decode("windows-1252")
u'\u2013'
pyunicodedata.name(_)
'EN DASH'
You actually *don't* get the character U+002D, HYPHEN-MINUS,
displayed - just a character that has, in your font, a glyph
which looks similar to the glyph for HYPHEN-MINUS.
However, HYPHEN-MINUS and EN DASH are different characters, and
IDLE displays the latter, not the former.
I tried searching "en dash" or even "dash" into the encodings folderYou didn't ask a specific question, so I assume you are primarily
of python Lib, but I couldn't find anything.
after an explanation.
HTH,
Martin