helwardany / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Interpreter window doesn't display Unicode results in readable format #619

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use a method to translate characters encoded as quoted printable to UTF-8, 
e.g. e-acute '=E9' to 'é'.
A table contains, among others: '=3D':'=', '=E9':'é', ...
2. Execute script (coded as UTF-8) which uses the method.
3. Examine the Interpreter window.

What is the expected output (Interpreter window)? 
 input: cn=3Djos=E9_afranio/o=3Ddomain
output: cn=josé afranio/o=domain
What do you see instead (Interpreter window)?
 input: cn=3Djos=E9_afranio/o=3Ddomain
output: cn=josé afranio/o=domain

What version of the product are you using? On what operating system?
2.4.3.0 on Windows XP Professional

Please provide any additional information below.
I imagine that it would be useful to allow one to change format on the 
Interpreter window; it seems to be showing raw UTF-8, which does not allow one 
to quickly check whether conversion is OK.

Original issue reported on code.google.com by pastr...@gmail.com on 7 Mar 2012 at 1:53

Attachments:

GoogleCodeExporter commented 9 years ago
p.s. Python 2.7.2

Original comment by pastr...@gmail.com on 7 Mar 2012 at 2:12

GoogleCodeExporter commented 9 years ago
The code has problems.  In Python 2.x unicode strings are prefixed with u. 
Change the script to 

wordDic = \
{
  '_':u' ',
'=2C':u',',
'=3D':u'=',
'=5B':u'[',
'=5D':u']',
'=7E':u'~',
'=C0':u'À', '=C1':u'Á', '=C2':u'Â', '=C3':u'Ã',
'=E0':u'à', '=E1':u'á', '=E2':u'â', '=E3':u'ã',
'=C7':u'Ç',
'=E7':u'ç',
'=C9':u'É', '=CA':u'Ê',
'=E9':u'é', '=EA':u'ê',
'=CD':u'Í', '=ED':u'í',
'=D3':u'Ó', '=D4':u'Ô', '=D5':u'Õ',
'=F3':u'ó', '=F4':u'ô', '=F5':u'õ',
'=DA':u'Ú',
'=FA':u'ú'
}

Further below:

out1 = multipleReplace(out0.decode(), wordDic)

and then the code should work as expected.

Please see PyScripter help topic "Encoded Python Source Files" 

Original comment by pyscripter on 7 Mar 2012 at 2:39

GoogleCodeExporter commented 9 years ago
Thank you very much.
Your dedication (expressed by the prompt response and detailed directions)
is appreciated.
As you may have noted, it was my very first code in Python: I was testing
different approaches with regex.

Will dig further on Unicode issues.

Original comment by pastr...@gmail.com on 7 Mar 2012 at 6:22