473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

raw_input encoding diferent from code encoding problem

al san
2
Hello, everyone, any help wil be greatly appreciated.

I'm writing code for a japanese learning app in python;
so all my japanese strings have are preceeded by 'u' (eg. u'にほんご'); Everthing works like a charm, except for when I get input from the user.
Expand|Select|Wrap|Line Numbers
  1. >>> internal=[u'\u306f\u3057\u3063\u305f', u'\u306f\u3057\u3063\u3066', u'\u306f\u3057\u3089\u306a\u3044', u'\u306f\u3057\u308a\u307e\u3059', u'\u306f\u3057\u308b', u'\u306f\u3057\u308c', u'\u306f\u3057\u308d\u3046']
  2. >>> user_input=['\x82\xcd\x82\xb5\x82\xc1\x82\xbd', '\x82\xcd\x82\xb5\x82\xc1\x82\xc4', '\x82\xcd\x82\xb5\x82\xe7\x82\xc8\x82\xa2', '\x82\xcd\x82\xb5\x82\xe8\x82\xdc\x82\xb7', '\x82\xcd\x82\xb5\x82\xe9', '\x82\xcd\x82\xb5\x82\xea', '\x82\xcd\x82\xb5\x82\xeb\x82\xa4']
  3. >>> for i in range (len(internal)):
  4.     print "code data: %s" % internal[i]
  5.     print "raw_input: %s" % user_input[i]
  6.  
  7. code data: はしった
  8. raw_input: はしった
  9. code data: はしって
  10. raw_input: はしって
  11. code data: はしらない
  12. raw_input: はしらない
  13. code data: はしります
  14. raw_input: はしります
  15. code data: はしる
  16. raw_input: はしる
  17. code data: はしれ
  18. raw_input: はしれ
  19. code data: はしろう
  20. raw_input: はしろう
  21. >>> 
As you can see, on the screen the text looks the same, but, behind the scenes the two encodings are totally different from eachother.
Why is this an issue?
Well, because I need to compare the two texts(raw_input vs program data) and if they
look the same on the screen, then I need the result to be True not False...

Thank you for your time.
Cheers
Dec 10 '10 #1
0 1976

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Fernando Rodriguez | last post by:
Hi, I just upgraded to Python2.3 and I'm getting a weird warning complaining about the encoding and asking me to read a pep. OK, I read the Pep and know what syntax to specify the enconding: #...
2
by: Donal McWeeney | last post by:
Hi, I think I may have a slight encoding problem with what I am doing. I have a test console app that takes an xml document and splits it into a number of smaller xml documents. First thing...
5
by: Hardy Wang | last post by:
Hi, I have following code: Encoding mode; // Encoding.Default or Encoding.UTF8 FileStream sb = new FileStream(fullPathAndFileName, FileMode.Create); StreamWriter sw = new StreamWriter(sb, mode);...
2
by: kevin | last post by:
DISCLAIMER: I know what the words mean (i.e. by definition), but I in know way pretend to understand the specifics of either, therefore I may need a basic primer before I can accomplish this task,...
0
by: Ryan Scully | last post by:
Hello I am having a problem with code not being rendered. I have a checkboxlist that is databinded in the Not Page.IsPostBack() sub, and the visibility is set to true/false depending on certain...
2
by: David Scemama | last post by:
Hi, I'm developing an application that reads data from a file. The data has been encoded using code page 850. I use the FileOpen function to open the file and the FileGet function to read the...
0
by: Jan Jones | last post by:
Hi, I have two XSDs both in seperate namespaces, Child is an extension of the abstract Base: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="Base"...
1
by: Daniel | last post by:
how does ado.net SqlDataReader.GetString() know which encoding to read the data into a string as? Does sql sever set this at the column data type level, server wide encoding setting, os encoding?
5
by: recordlovelife | last post by:
So i have written a code to encode a string of a select amount of letters into huffman code. #include <iostream> #include <string> using namespace std; string Huffman(char letter);...
5
by: Joe | last post by:
Hi, When I start a new VS2005 website project, have a .aspx page and I drop a control onto it and when I double-click on the event, it brings up the .aspx.vb file so that I can add the VB event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.