The documentation for the Encode module says this about handling malformed characters while encoding:

CHECK = Encode::FB_DEFAULT ( == 0)

If CHECK is 0, encoding and decoding replace any malformed character with a substitution character. When you encode, SUBCHAR is used.

How can I specify, or at least query, what the substitution characters is for a particular encoding. I'm interested in iso-8859-1.

有帮助吗?

解决方案

You can't, but you can use a callback to achieve the same effect.

$ perl -MEncode -E'say encode("iso-8859-1", "ab\x{2660}d\x{E9}f")' \
   | iconv -f iso-8859-1
ab?déf

$ perl -MEncode -E'say encode("iso-8859-1", "ab\x{2660}d\x{E9}f", sub { "*" })' \
   | iconv -f iso-8859-1
ab*déf
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top