Unicode::GCString 错误消息:“新:必须给出 Unicode 字符串”
这里可能出了什么问题:我收到错误消息新:Unicode 字符串必须在...
对于线路$gvalue = Unicode::GCString->new( $value );
use Unicode::GCString;
# ....
# ....
my $width = 0;
my $gvalue;
if ( $value ) {
$gvalue = Unicode::GCString->new( $value );
$width = $gvalue->columns();
}
# ....
# new: Unicode string must be given. at ...
$values
的形式如下:
for my $i ( 0 .. $#$ref ) {
for my $j ( 0 .. $#{$ref->[$i]} ) {
my $value = $ref->[$i][$j] // '';
# ...
到目前为止,测试时 $ref
是硬编码的在脚本中,但它应该成为一个模块,并且 $ref
应该在例程中移动。
What could here be wrong: I get the error-messagenew: Unicode string must be given at ...
for the line$gvalue = Unicode::GCString->new( $value );
use Unicode::GCString;
# ....
# ....
my $width = 0;
my $gvalue;
if ( $value ) {
$gvalue = Unicode::GCString->new( $value );
$width = $gvalue->columns();
}
# ....
# new: Unicode string must be given. at ...
$values
comes form:
for my $i ( 0 .. $#$ref ) {
for my $j ( 0 .. $#{$ref->[$i]} ) {
my $value = $ref->[$i][$j] // '';
# ...
Until now while testing $ref
is hardcoded in script but then it should become a module and $ref
should be shifted in a routine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Unicode::GCString 存在 Unicode Bug(为 UTF8 标志赋予含义):
它期望使用 UTF8=1 内部存储格式存储字符串。您可以使用 utf8::upgrade 强制字符串采用正确的格式,但这也可能表明您忘记解码字符串。
Unicode::GCString suffers from the Unicode Bug (assigns meaning to the UTF8 flag):
It expects a string in stored using the UTF8=1 internal storage format. You can force the string to the right format using
utf8::upgrade
, but it could also be a sign that you forgot to decode the string.我忘记设置
use utf8
(并且我必须明确地字符串化$gstring->as_string
)。I forgot to set
use utf8
(and I had to stringify explicitly$gstring->as_string
).