I have set of accented characters like this
I want to convert upper case accented characters to lower case. I used the lc
operator, but I can't get the expected output.
For example, I want to convert Â
to â
.
If I take an XML entity like Â
, if I converted it to lower case it should become â
#!/usr/bin/perl
use warnings;
use strict;
use Encode qw(encode decode);
my $enc = 'utf-8'; # This script is stored as UTF-8
my $str = "Ä\n";
# Byte strings:
print lc $str; # prints 'Ä', lc didn't have any effect
# text strings::
my $text_str = decode($enc, $str);
$text_str = lc $text_str;
print encode($enc, $text_str); # prints 'ä', lc worked as expected
Try it this may work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With