我需要正常化字符串,如「quée」,我似乎無法將擴展的ASCII字符(如é,á,í等)轉換爲羅馬/英文版本。我嘗試了幾種不同的方法,但目前爲止沒有任何效果。這個主題有相當數量的資料,但我似乎無法找到有效解決這個問題的答案。正常化ASCII字符
這裏是我的代碼:
#transliteration solution (works great with standard chars but doesn't find the
#special ones) - I've tried looking for both \x{130} and é with the same result.
$mystring =~ tr/\\x{130}/e/;
#converting into array, then iterating through and replacing the specific char
#(same result as the above solution)
my @breakdown = split("",$mystring);
foreach (@breakdown) {
if ($_ eq "\x{130}") {
$_ = "e";
print "\nArray Output: @breakdown\n";
}
$lowercase = join("",@breakdown);
}
精彩的解決方案,它很棒!謝謝! –