473,785 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert on uppercase unaccentent unicode character

JBJ
Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his uppercase
unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
½,¼ should return ¼
i,I,î,Î should return I

Have you some suggestions ?

Thank.
Oct 3 '07 #1
12 2607
On Oct 4, 7:35 am, JBJ <Jean-Bernard.jacquet-at-tele-deux-
point...@invali d.orgwrote:
Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his uppercase
unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
½,¼ should return ¼
i,I,î,Î should return I

Have you some suggestions ?

Thank.
Unicode strings have an upper() method - try that. I'm think it
should work properly with your locale - it doesn't give the expected
result for me with an english locale.

Oct 3 '07 #2
ti******@gmail. com wrote:
On Oct 4, 7:35 am, JBJ <Jean-Bernard.jacquet-at-tele-deux-
point...@invali d.orgwrote:
>Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his
uppercase unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
½,¼ should return ¼
i,I,î,Î should return I

Have you some suggestions ?

Thank.

Unicode strings have an upper() method - try that. I'm think it
should work properly with your locale - it doesn't give the expected
result for me with an english locale.
No, that will uppercase the string, but it doesn't (and shouldn't) strip
the accents:
>>s = u'''By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
½,¼ should return ¼
i,I,î,Î should return I'''
>>print s.upper()
BY EXAMPLE WITH LOCALE FR_FR:
A,A,À,À SHOULD RETURN A
O,O,Ô,Ô SHOULD RETURN O
½,¼ SHOULD RETURN ¼
I,I,Î,Î SHOULD RETURN I
>>>
I guess maybe my newreader corrupted the third line. It probably corrupts
all the others when I send this.
Oct 3 '07 #3
On Oct 4, 4:35 am, JBJ <Jean-Bernard.jacquet-at-tele-deux-
point...@invali d.orgwrote:
Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his uppercase
unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
½,¼ should return ¼
i,I,î,Î should return I

Have you some suggestions ?

Thank.
Google in this newsgroup for a thread started by "bussiere" on or
about 2006-03-25. The code snippet provided by Fredrik Lundh should
help you.
Oct 3 '07 #4
Duncan Booth wrote:
ti******@gmail. com wrote:
>On Oct 4, 7:35 am, JBJ <Jean-Bernard.jacquet-at-tele-deux-
point...@inval id.orgwrote:
>>Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his
uppercase unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
½,¼ should return ¼
i,I,î,Î should return I

Have you some suggestions ?

Thank.
Unicode strings have an upper() method - try that. I'm think it
should work properly with your locale - it doesn't give the expected
result for me with an english locale.
No, that will uppercase the string, but it doesn't (and shouldn't) strip
the accents:
I can agree that is doesn't (though I am taking your word for it), but a
French person will definitely feel it's doing the wrong thing. Upper
case letters aren't accented in written French.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

Oct 3 '07 #5
Steve Holden <st***@holdenwe b.comwrote:
>No, that will uppercase the string, but it doesn't (and shouldn't)
strip the accents:
I can agree that is doesn't (though I am taking your word for it), but
a French person will definitely feel it's doing the wrong thing. Upper
case letters aren't accented in written French.
I didn't know that, and I'm not sure I believe it: but then the French
tend to have conventions honoured more in the breach than the observance. I
just hit a few French websites, and the first one that I found which had
any capital letters that might be accented had four accented capital
letters on its front page (two capitalized words and two words in block
capitals).
Oct 3 '07 #6
On Oct 4, 7:06 am, Duncan Booth <duncan.bo...@i nvalid.invalidw rote:
Steve Holden <st...@holdenwe b.comwrote:
No, that will uppercase the string, but it doesn't (and shouldn't)
strip the accents:
I can agree that is doesn't (though I am taking your word for it), but
a French person will definitely feel it's doing the wrong thing. Upper
case letters aren't accented in written French.

I didn't know that, and I'm not sure I believe it: but then the French
tend to have conventions honoured more in the breach than the observance. I
just hit a few French websites, and the first one that I found which had
any capital letters that might be accented had four accented capital
letters on its front page (two capitalized words and two words in block
capitals).
The usual rationale for such treatment of accented characters is for
fuzzy matching:
if upshiftedunacce nted(text1) == upshiftedunacce nted(text2):
Oct 4 '07 #7
In message <Xn************ *************@1 27.0.0.1>, Duncan Booth wrote:
Steve Holden <st***@holdenwe b.comwrote:
>>No, that will uppercase the string, but it doesn't (and shouldn't)
strip the accents:
I can agree that is doesn't (though I am taking your word for it), but
a French person will definitely feel it's doing the wrong thing. Upper
case letters aren't accented in written French.
I didn't know that, and I'm not sure I believe it: but then the French
tend to have conventions honoured more in the breach than the observance.
Second most diabolical spelling system in the world ... after English.
Oct 4 '07 #8
JBJ
Steve Holden wrote:
Duncan Booth wrote:
>ti******@gmail. com wrote:
>>On Oct 4, 7:35 am, JBJ <Jean-Bernard.jacquet-at-tele-deux-
point...@inva lid.orgwrote:
Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his
uppercase unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
?,? should return ?
i,I,î,Î should return I

Have you some suggestions ?

Thank.
Unicode strings have an upper() method - try that. I'm think it
should work properly with your locale - it doesn't give the expected
result for me with an english locale.
No, that will uppercase the string, but it doesn't (and shouldn't) strip
the accents:
I can agree that is doesn't (though I am taking your word for it), but a
French person will definitely feel it's doing the wrong thing. Upper
case letters aren't accented in written French.

regards
Steve
http://www.academie-francaise.fr/lan...l#accentuation
Regards
Oct 4 '07 #9
JBJ
John Machin wrote:
On Oct 4, 4:35 am, JBJ <Jean-Bernard.jacquet-at-tele-deux-
point...@invali d.orgwrote:
>Hi,
I'am very newbie in Python.
For the moment I'am trying to convert an unicode character to his
uppercase unaccented character.
By example with locale fr_FR:
a,A,à,À should return A
o,O,ô,Ô should return O
?,? should return ?
i,I,î,Î should return I

Have you some suggestions ?

Thank.

Google in this newsgroup for a thread started by "bussiere" on or
about 2006-03-25. The code snippet provided by Fredrik Lundh should
help you.
Thanks
Oct 4 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
25953
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner, so I assume it's simplest to convert to lower/upper first. Possibly all strings will be from the latin-1 character set, so I could convert to 8-bit latin-1, map to lowercase, and convert back, but that seems rather cumbersome.
30
21859
by: rh0dium | last post by:
Hi All, While I know there is a zillion ways to do this.. What is the most efficient ( in terms of lines of code ) do simply do this. a=1, b=2, c=3 ... z=26 Now if we really want some bonus points.. a=1, b=2, c=3 ... z=26 aa=27 ab=28 etc..
30
8678
by: John Carroll | last post by:
Does anyone have a function or procedure for converting integers to character strings? Thank you, John
8
14333
by: davihigh | last post by:
My Friends: I am using std::ofstream (as well as ifstream), I hope that when i wrote in some std::string(...) with locale, ofstream can convert to UTF-8 encoding and save file to disk. So does ifstream. Something I found shows that, I need to have a proper codecvt to set it. I need more information, maybe a small piece of code sample. Thank you!
8
20338
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single , double, triple byte etc). I need to convert to upper case only those characters which has got upper case. ie if an user enter bot english and japanese characters in the text field, then I should convert only english characters, not japanese.
3
13840
by: GM | last post by:
Dear all, Could you all give me some guide on how to convert my big5 string to unicode using python? I already knew that I might use cjkcodecs or python 2.4 but I still don't have idea on what exactly I should do. Please give me some sample code if you could. Thanks a lot Regards, Gary
0
5069
by: deloford | last post by:
Hi This is going to be a question for anyone who is an expert in C# Text Encoding. My situation is this: I have a Sybase database which is firing back ISO-8559 encoded strings. I am unable to get the db to translate to UTF-8 for non technical reasons. So I have a string coming back with the character œ (ISO value 156). this character appears in .NET as a box character because 156 is not a valid Unicode character value. I have been...
0
571
by: M.-A. Lemburg | last post by:
On 2008-07-01 20:31, Peter Bulychev wrote: You could write a codec which translates Unicode into a ASCII lookalike characters, but AFAIK there is no standard for doing this. I guess the best choice is to use the Unicode code point names as basis. These can be accessed via unicodedata.name(). You can then create a mapping which can be processed by the character map codec.
19
5343
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that str(object) does not always attempt to return a string that is acceptable to eval(); its goal is to return a printable string. If no argument is given, returns the empty string, ''.
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.