Matheus Tavares | 2fa3cba | 2021-05-04 13:27:33 -0300 | [diff] [blame] | 1 | # Encoding helpers |
| 2 | |
| 3 | test_lazy_prereq NO_UTF16_BOM ' |
| 4 | test $(printf abc | iconv -f UTF-8 -t UTF-16 | wc -c) = 6 |
| 5 | ' |
| 6 | |
| 7 | test_lazy_prereq NO_UTF32_BOM ' |
| 8 | test $(printf abc | iconv -f UTF-8 -t UTF-32 | wc -c) = 12 |
| 9 | ' |
| 10 | |
| 11 | write_utf16 () { |
| 12 | if test_have_prereq NO_UTF16_BOM |
| 13 | then |
| 14 | printf '\376\377' |
| 15 | fi && |
| 16 | iconv -f UTF-8 -t UTF-16 |
| 17 | } |
| 18 | |
| 19 | write_utf32 () { |
| 20 | if test_have_prereq NO_UTF32_BOM |
| 21 | then |
| 22 | printf '\0\0\376\377' |
| 23 | fi && |
| 24 | iconv -f UTF-8 -t UTF-32 |
| 25 | } |