gpt4 book ai didi

perl - 使用 Perl 将重音字符更改为小写

转载 作者:行者123 更新时间:2023-12-04 22:46:09 24 4
gpt4 key购买 nike

我有一组像这样的重音字符

<code>enter image description here</code>

我想将大写重音字符转换为小写。我用了 lc运算符,但我无法获得预期的输出。

例如,我想转换 Ââ .

如果我采用像 &#x00C2 这样的 XML 实体,如果我把它转换成小写,它应该变成 &#x00E2

最佳答案

#!/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

试试这可能会奏效。

关于perl - 使用 Perl 将重音字符更改为小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25153462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com