develooper Front page | perl.ldap | Postings from October 2010

Converting from UTF-8 to ASCII for gecos field.

Thread Next
From:
Prentice Bisbal
Date:
October 14, 2010 11:47
Subject:
Converting from UTF-8 to ASCII for gecos field.
Message ID:
4CB7504E.9090201@ias.edu
Greetings.

Can anyone suggest a good way of converting a string from UTF-8 to IA5
(ASCII) for the gecos attribute. For example, I have the hypotheical
user Ërïç Cärtmân, with a lot of accented characters in his name
converting his name to ASCII using this code:

my $gecos = encode('ascii', $cn);

Turns it into this ugly mess:

gecos: ?r?? C?rtm?n

Anyone know of any decent perl functions that could turn it into
something more readable, like "Eric Cartman"?

Trying to setup regular expressions would be a nightmare.


-- 
Prentice

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About