[I18n-sig] Literal strings

M.-A. Lemburg mal@lemburg.com
Mon, 05 Jun 2000 14:43:52 +0200


Paul Prescod wrote:
> 
> "M.-A. Lemburg" wrote:
> >
> > ....
> 
> > The safest way to do this certainly is by fixing all
> > instances to use u"" instead of "" (not that hard, really).
> > Even though this may look strange at first, reading the code
> > will immediately bring your attention to the fact that you
> > are dealing with Unicode here -- a #pragma at the top won't
> > get that much attention and a casual user might wonder
> > where the u"" strings in variable dumps originate from.
> 
> I guess that's our philosophical difference. I don't want to go around
> thinking about the fact that I am using Unicode. I want to test it
> once and then have it "just work."

That won't always work... 

Unicode and strings are two different
things -- the first is explicitely there for text data
while the second can hold arbitrary data with no extra
meta information attached.

...if it does work, then you're lucky ;-)
 
> > One way to do this is by turning
> > all "" string literals into u"" assuming the encoding
> > given in the #pragma e.g. Latin-1 or MacRoman -- this would
> > be along the lines of what you have in mind.
> 
> Yes, this would probably be acceptable.
> 
> > The problem
> > with this is that some string literaly might have to map
> > to 8-bit strings, so for these you'd need to write e.g.
> > s"" or something similar.
> 
> Right, or call a conversion function.

...but then you have the same problem as before: string
literal modifiers (the small 'u' or 's' in front of the
literal) scattered around in the source code.

Hmm, we need some more ideas in this area I guess...

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/