unicode

python, and unicode stderr

I used an anonymous pipe to capture all stdout,and stderr then print into a richedit, it's ok when i use wsprintf ,but the python using multibyte char that really annoy me. how can I convert all these output to unicode? UPDATE 2010-01-03: thanx for the reply. but, it seems the str.encode() only worked with print xxx stuff, if there is ...

MySQL VARCHAR Lengths and UTF-8

In MySQL, if I create a new VARCHAR(32) field in a UTF-8 table does it means I can store 32 bytes of data in that field or 32 chars (multi-byte)? ...

Why does it print funny characters? unicode problem?

The user entered the word éclair into the search box. Showing results 1 - 10 of about 140 for �air. Why does it show the weird question mark? I'm using Django to display it: Showing results 1 - 10 of about 140 for {{query|safe}} ...

How do i use Django and UTF-8 content-type for template?

When I do: return render_to_response() in Django. How do I set the content-type to UTF-8? So that everything displayed is UTF-8? ...

Why does Django admin try to encode strings into ASCII rather than Unicode? Or is this error something different than it looks like?

I've got the following error: TemplateSyntaxError at /admin/results_cop/copsegmentresult/ Caught an exception while rendering: ('ascii', 'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96', 98, 99, 'ordinal not in range(128)') The fragment of the s...

UnicodeEncodeError on joining file name

It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code: filename = 'Spywaj.ttf' print repr(filename) >> 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) But the file is valid and existed on disk. Filename was extracted from "unzi...

How can I get a Unicode character's code?

Let's say I have this: char registered = '®'; or an umlaut, or whatever unicode character. How could I get its code? ...

Any ideas on optimizing this script? (Python)

I'm working on a little script to help me learn the Japanese Kana (Hiragana/Katakana). In total, there are probably 100+ (+||-). Basically, all it would do is take in the english version and convert it to the character. ie. a = 'あ' which is 12354 in decimal What I have so far is this: hiraDict = { "a" : 12354, "i" : 12356 ...} if ...

unicode error when saving an object in django admin

Hello, In my django app, I have some objects that cause the corresponding URL in the django admin to be non ascii. (for example: http://mysite/admin/myapp/myclass/Présentation/) I can edit the object without any problem but when I save it I have the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in p...

Given a unicode error I don't understand.

Here is my code, I'm sure it looks terrible but it all works as it should, only problem I'm having is with the last line... import pyPdf import os import csv class UnicodeWriter: """ A CSV writer which will write rows to CSV file "f", which is encoded in the given encoding. """ def __init__(self, f, dialect=csv.exc...

How to Connect With Microsoft Localization Center

Windows uses an invalid codepage for keyboard layout in my language, I'm wonderf if there is a way to connect with Microsoft Windows Localization Center and give them the right keyboard layout to put in windows, I try this in Windows blog (by commenting) and e-mailing with some good guy that I knew but no feedback received. I'm still w...

python json unicode - how do I eval using javascript

Really spent a lot of time searching for this. Please need some help. I am trying to add multilingual feature to my web app framework. For this I am unable to send non ascii characters as JSON. Here is what I am doing Here is what I get from the database '\xe0\xa4\xa4\xe0\xa5\x87\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4' which when I pri...

Using Ruby 1.9.1, how could I access this string's characters one at a time?

I don't know how else to explain, so I'll give you List of greek words with english derivatives. Look at the a table, please, first column. Notice there are words like ἄβαξ. Using Ruby 1.9.1, which has better encoding support than Ruby 1.8, how could I iterate over each character forming that word? For example, I'd like to get the letter...

Detect and filter user input depending on charset

Hi, I am trying to filter user input depending on their charset. I am displaying keywords from user inputs to other users but to not want to display e.g. arabic or chinese characters but only english/latin characters. How can I do that with PHP? Is there a easy solution on doing this? Thanks. ...

What is the relationship between 'unicode' and 'encode'

print u'\xe4\xf6\xfc'.encode('utf-8') print unicode(u'\xe4\xf6\xfc') traceback: 盲枚眉 Traceback (most recent call last): File "D:\zjm_code\a.py", line 6, in <module> print unicode(u'\xe4\xf6\xfc') UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) python shell >>>u"äöü".encode...

What kind of strings does CFStringCreateWithFormat expects as arguments?

The below example should work with Unicode strings but it doesn't. CFStringRef aString = CFSTR("one"); // in real life this is an Unicode string CFStringRef formatString = CFSTR("This is %s example"); // also tried %S but without success CFStringRef resultString = CFStringCreateWithFormat(NULL, NULL, formatString, aString); // Here I...

javascript - how to convert unicode string to ascii

I need to convert unicode string to ascii to make a nice string for friendly url. Dont's ask me why dont do this in server side, please. ...

Blogger and unicode ?

I have two questions Can this code be added to blogger? Can this code embed unicode fonts? and if can, please tell me the link how to do it. ...

How can I treat command-line arguments as UTF-8 in Perl?

How do I treat the elements of @ARGV as UTF-8 in Perl? Currently I'm using the following work-around .. use Encode qw(decode encode); my $foo = $ARGV[0]; $foo = decode("utf-8", $foo); .. which works but is not very elegant. I'm using Perl v5.8.8 which is being called from bash v3.2.25 with a LANG set to en_US.UTF-8. ...

What is the optimal multiplatform way of dealing with Unicode strings under C++?

I know that there are already several questions on StackOverflow about std::string versus std::wstring or similar but none of them proposed a full solution. In order to obtain a good answer I should define the requirements: multiplatform usage, must work on Windows, OS X and Linux minimal effort for conversion to/from platform specif...