Re: Why does the "".join(r) do this?

From: Peter Otten (__peter___at_web.de)
Date: 05/20/04


Date: Thu, 20 May 2004 23:13:29 +0200

John Roth wrote:

> "Ivan Voras" <ivoras@__geri.cc.fer.hr> wrote in message
> news:c8itrm$epg$1@bagan.srce.hr...

>> Is there a way to change the default codec in a part of a program?
>> (Meaning that different parts of program deal with strings they know are
>> in a specific different code pages?)
>
> Does the encoding line (1st or second line of program) do this?
> I don't remember if it does or not - although I'd suspect not.
> Otherwise it seems like a reasonably straightforward function
> to write.

As a str does not preserve information about the encoding, the
# -*- coding: XXX -*-
comment does not help here. It does however control the decoding of unicode
strings. I suppose using unicode for non-ascii literals plus the above
coding comment is as close as you can get to the desired effect.

With some more work you could probably automate string conversion like it is
done with quixote's htmltext. Not sure if that would be worth the effort,
though.

Peter



Relevant Pages

  • Re: Unicode/UTF-8 decoding
    ... I am using SQLyog to access mySQL remotely. ... This text looks as it has been decoded with a different encoding than ... If you want to store unicode strings in the MySQL database, ... While this gives the correct result for some strings, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Best ways of managing text encodings in source/regexes?
    ... etc. when compiling regexes with python's re.UNICODE flag. ... the encoding of one's source strings when building regexes, ... READ TO/WRITE FROM UNICODE STRING OBJECTS. ...
    (comp.lang.python)
  • Re: Proposal: require 7-bit source strs
    ... I'm referring to a time when there was no encoding ... It would be possible to go back and find all strings ... That's why I specified to do this after conversion to ... make the assumption that the character set is ASCII-based, ...
    (comp.lang.python)
  • Re: pep 277, Unicode filenames & mbcs encoding &c.
    ... PEP 277 actually answers neither question. ... changes only affect Unicode strings passed to functions expecting file names. ... > system encoding to convert strings to Unicode, ...
    (comp.lang.python)
  • Re: Using Japanese and English strings, encodings
    ... English, and I keep wishing I could closely, reliable, and simply ... using edict + CLISP + araneida. ... It keeps screwing up the EUC-JP encoding of any parameters I ... Internally, strings are 16 bit characters, I think. ...
    (comp.lang.lisp)