Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'languages.': 0.04; 'remaining': 0.07; 'locale': 0.09; 'received:internal': 0.09; '8-bit': 0.16; 'lowercase': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'set,': 0.16; 'uppercase': 0.16; 'wrote:': 0.18; 'example': 0.22; 'skip:l 30': 0.24; 'unicode': 0.24; 'mon,': 0.24; 'versions': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'generally': 0.29; 'characters': 0.30; 'matching': 0.30; 'era': 0.31; 'sets.': 0.31; 'received:66': 0.35; 'skip:u 20': 0.35; 'there': 0.35; 'european': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'example,': 0.37; 'two': 0.37; 'received:10': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'letters': 0.60; 'from:no real name:2**0': 0.61; 'affect': 0.61; "you're": 0.61; 'header:Message-Id:1': 0.63; 'different': 0.65; '20,': 0.68; 'russian': 0.74; '2014,': 0.84; 'isolated': 0.84; 'western': 0.86; 'whereas': 0.91; 'have.': 0.93 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=vm4kabTtqUpCQV57JLhQvzsC+ak=; b=GXGt FuWzDei3LPlrUnrVCIXenB7CH6MGpAFCFEaUlXHIvMzv5iyGWWfMN/HWCF3DvoPr TnP0Jifw+KPDEMNKGxBq2ouyu6yG/KoUe0zWaIcewhyT6gSwOGBBOiHXqSJJ4j3O jPZf8JnlDi0zaKTZZt1BOivvvETzrlEQa59PEhQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=vm4kabTtqUpCQV57JLhQvzsC +ak=; b=PFJ3QsD/e0eiykSp0mELi7PON1TaV2sEFQFftd6jH+bZcx8ESMQ/g8oj Fmsa1QHAQzQaVChku8DBuz23YLGBcGGMR4TbpJwAAIdkF+PH+UfT4TY2Z6HZnn2i a2q9k5YL9YFySejAY8LkAiOCPxT3u6kNQ9iHzX7FFMPWErOQJxE= X-Sasl-Enc: JSpYiA9xye42zlu1z9/CMoAsZbEywTy6rD8N23WItHD8 1413895252 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-e69fc525 In-Reply-To: <1413837229.47847.BPMail_high_carrier@web163802.mail.gq1.yahoo.com> References: <1413837229.47847.BPMail_high_carrier@web163802.mail.gq1.yahoo.com> Subject: Re: real-life example LC_CTYPE effects? Date: Tue, 21 Oct 2014 08:40:52 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413895256 news.xs4all.nl 2860 [2001:888:2000:d::a6]:57658 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:79376 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.