문제

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