Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79376

Re: real-life example LC_CTYPE effects?

From random832@fastmail.us
References <1413837229.47847.BPMail_high_carrier@web163802.mail.gq1.yahoo.com>
Subject Re: real-life example LC_CTYPE effects?
Date 2014-10-21 08:40 -0400
Newsgroups comp.lang.python
Message-ID <mailman.15030.1413895256.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Oct 20, 2014, at 16:33, Albert-Jan Roskam wrote:
> Hi,
> 
> The locale category LC_CTYPE may affect character classification and case
> conversion.
> 
> That's the theory. Can you give a practical example where this locale
> setting matters? Eg.:
> locale.setlocale(locale.LC_CTYPE, loc)
> m = re.match("\d+", s, re.I | re.L)
> 
> So with two different values for loc, and s is identical, there will or
> won't be a match.

You're generally isolated from this by using unicode strings - there are
only a few unicode characters that have different case mappings in
different languages. LC_CTYPE was designed in an era of 8-bit character
sets. For example, in a Russian locale with KOI8-R character set, C0-DF
are all lowercase letters, and E0-FF are all the uppercase equivalent,
whereas in an English or other western european locale with ISO-8859-1,
C0-DF [except D7] are all uppercase letters, with the lowercase versions
in E0-FF [except F7], and in a Hebrew ISO-8859-8 locale only E0-FA are
letters and are not uppercase/lowercase.

Try setting the locale to tr_TR and matching "i" against "I", for a
demonstration of one of the few remaining effects this can have.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: real-life example LC_CTYPE effects? random832@fastmail.us - 2014-10-21 08:40 -0400

csiph-web