Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这两个代码片段是否相同?
utf8::upgrade( $s );
use Encode qw(is_utf8 decode); $s = is_utf8( $s ) ? $s : decode( 'latin1', $s );
制作副本及其含义不谈,它们是同一件事,但只是因为如何decode('latin1', $_)处理无效的 latin1 字符串,例如"\x90".
decode('latin1', $_)
"\x90"
该表达式返回不同的内容(内部使用的字节数 vs $s),但我认为您正在丢弃它。
$s
我希望你问,因为你想用前者代替后者!