To be able to decode a string successfully, I need to know what coding
it is in.
The string can be coded in utf8 or in windows-1250 or in another
coding.
Is there a method how to find out the string coding.
Thank you for help
L. 8 2827
Lad wrote:
To be able to decode a string successfully, I need to know what coding
it is in.
ask whoever provided the string.
The string can be coded in utf8 or in windows-1250 or in another
coding. Is there a method how to find out the string coding.
in general, no. if you have enough text, you may guess, but the right
approach for that depends on the application.
</F>
Fredrik Lundh wrote:
Lad wrote:
To be able to decode a string successfully, I need to know what coding
it is in.
ask whoever provided the string.
The string can be coded in utf8 or in windows-1250 or in another
coding. Is there a method how to find out the string coding.
in general, no. if you have enough text, you may guess, but the right
approach for that depends on the application.
</F>
Fredrik,
Thank you for your reply
The text is from Mysql table field that uses utf8_czech_ci collation,
but when I try
`RealName`.decode('utf8'),where RealName is that field of MySQL
I will get:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3:
ordinal
not in range(128)
Can you please suggest the solution?
Thank you
L.
In <11**********************@m73g2000cwd.googlegroups .com>, Lad wrote:
The text is from Mysql table field that uses utf8_czech_ci collation,
but when I try
`RealName`.decode('utf8'),where RealName is that field of MySQL
I will get:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3:
ordinal
not in range(128)
Can you please suggest the solution?
Do you get this from converting the value from the database or from trying
to print the unicode string? Can you give us the output of
print repr(RealName)
Ciao,
Marc 'BlackJack' Rintsch
Marc 'BlackJack' Rintsch wrote:
In <11**********************@m73g2000cwd.googlegroups .com>, Lad wrote:
The text is from Mysql table field that uses utf8_czech_ci collation,
but when I try
`RealName`.decode('utf8'),where RealName is that field of MySQL
I will get:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3:
ordinal
not in range(128)
Can you please suggest the solution?
Do you get this from converting the value from the database or from trying
to print the unicode string? Can you give us the output of
print repr(RealName)
Ciao,
Marc 'BlackJack' Rintsch
for
print repr(RealName) command
I will get
P?ibylov\xe1 Ludmila
where instead of ? should be also a character
Thank you for help
L.
Lad wrote:
for
print repr(RealName) command
I will get
P?ibylov\xe1 Ludmila
where instead of ? should be also a character
that's not very likely; repr() always includes quotes, always escapes
non-ASCII characters, and optionally includes a Unicode prefix.
please try this
print "*", repr(RealName), type(RealName), "*"
and post the entire output; that is, *everything* between the asterisks.
</F>
Fredrik Lundh wrote:
Lad wrote:
for
print repr(RealName) command
I will get
P?ibylov\xe1 Ludmila
where instead of ? should be also a character
that's not very likely; repr() always includes quotes, always escapes
non-ASCII characters, and optionally includes a Unicode prefix.
please try this
print "*", repr(RealName), type(RealName), "*"
and post the entire output; that is, *everything* between the asterisks.
The result of print "*", repr(RealName), type(RealName), "*" is
* 'Fritschov\xe1 Laura' <type 'str'*
Best regards,
L
"Lad" wrote:
The result of print "*", repr(RealName), type(RealName), "*" is
* 'Fritschov\xe1 Laura' <type 'str'*
looks like the MySQL interface is returning 8-bit strings using ISO-8859-1
encoding (or some variation of that; \xE1 is "LATIN SMALL LETTER A
WITH ACUTE" in 8859-1).
have you tried passing "use_unicode=True" to the connect() call ?
</F>
Fredrik Lundh wrote:
"Lad" wrote:
The result of print "*", repr(RealName), type(RealName), "*" is
* 'Fritschov\xe1 Laura' <type 'str'*
looks like the MySQL interface is returning 8-bit strings using ISO-8859-1
encoding (or some variation of that; \xE1 is "LATIN SMALL LETTER A
WITH ACUTE" in 8859-1).
have you tried passing "use_unicode=True" to the connect() call ?
</F>
Frederik,
Thank you for your reply.
I found out that if I do not decode the string at all, it looks
correct. But I do not know why it is ok without decoding.
I use Django and I do not use use_unicode=True" to the connect() call. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon |
last post by:
Newbie alert!
I have a webform listbox with what I am sure is a common requirement. I wish
to store a list of values but display a "translation" or...
|
by: Guoqi Zheng |
last post by:
Dear sir,
I need to decode base64 encoded email.
I used below function but it does not work correctly, especially when I need
to decode some...
|
by: aurora |
last post by:
I have some unicode string with some characters encode using python
notation like '\n' for LF. I need to convert that to the actual LF
character....
|
by: rsd |
last post by:
Hi,
I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux.
To do that I need to run...
|
by: Oleg Parashchenko |
last post by:
Hello,
I'm working on an unicode-aware application. I like to use "print" to
debug programs, but in this case it was nightmare. The most popular...
|
by: Tim Arnold |
last post by:
Hi, I'm beginning to understand the encode/decode string methods, but I'd
like confirmation that I'm still thinking in the right direction:
I...
|
by: glacier |
last post by:
I use chinese charactors as an example here.
"'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'"
My first question is : what strategy does 'decode' use to tell...
|
by: Eric S. Johansson |
last post by:
I'm having a problem (Python 2.4) converting strings with random 8-bit
characters into an escape form which is 7-bit clean for storage in a...
|
by: d-fan |
last post by:
void decodebio( unsigned char *encbuf, unsigned char * decbuf, int
destbuf ) {
/* Read Base64 encoded data from standard input and write...
|
by: anonymous |
last post by:
1 Objective to write little programs to help me learn German. See code
after numbered comments. //Thanks in advance for any direction or...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |