大写Unicode的正则表达式与“Ó"不匹配? [英] Regex for uppercase Unicode does not match "Ó"?
本文介绍了大写Unicode的正则表达式与“Ó"不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎无法将重音符号Ó识别为大写字母
It seems that it does not recognize the accented Ó as uppercase
#!/usr/bin/env perl
use strict;
use warnings;
use 5.14.0;
use utf8;
use feature 'unicode_strings';
" SIMÓN " =~ /^\s+(\p{Upper}+)/u;
print "$1\n";
返回
SIM
Perl应该能够使用Unicode数据,该数据已经将Ó标记为大写.
从emacs describe-char
Perl should be able to use Unicode data, which already tags Ó as uppercase.
From emacs describe-char
character code properties: customize what to show
name: LATIN CAPITAL LETTER O WITH ACUTE
old-name: LATIN CAPITAL LETTER O ACUTE
general-category: Lu (Letter, Uppercase)
decomposition: (79 769) ('O' '́')
推荐答案
您缺少use open ':std', ':locale';
来正确编码输出.
You're missing use open ':std', ':locale';
to properly encode your output.
如果这不起作用,即使您告诉Perl,文件也不会使用UTF-8编码.
If that doesn't work, your file isn't encoded using UTF-8 even though you tell Perl it is.
这篇关于大写Unicode的正则表达式与“Ó"不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文