//i does work on accented characters ...usually. When it doesn't, you can force it to using one of the following methods:
- 5.8.1+
utf8::upgrade($_);
/.../i
- 5.12+ (or 5.14+?)
use feature 'unicode_strings';
/.../i
- 5.12+ (or 5.14+?)
use 5.012;
/.../i
- 5.14+
/.../iu
- 5.14+
use re '/u';
/.../i
A very likely possibility is that you don't actually have "é" or "É" in your string or in your code due to forgetting to decode, since you don't normally need the above.
use utf8; # Source file is encoded using UTF-8
print "é" =~ /É/i ?1:0,"\n"; # 1
print "É" =~ /é/i ?1:0,"\n"; # 1
print "é" =~ /\w/ ?1:0,"\n"; # 1
print "É" =~ /\w/ ?1:0,"\n"; # 1
To answer your question, you could go about doing that by lowercasing non-ASCII characters using s/([^\x00-\x7F])/lc($1)/eg; with one of the above used.
use utf8; # UTF-8 code
use open ':std', ':encoding(UTF-8)'; # UTF-8 terminal
use 5.012;
$_ = "LES MISÉRABLES";
s/([^\x00-\x7F])/lc($1)/eg; # LES MISéRABLES
say;
|