• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5# Example characters from https://en.wikipedia.org/wiki/UTF-16:
6# $:U+0024  €:U+20ac  ��:U+10437[==U+d801,U+dc37]
7# We can't simply use echo because bash 3.2 on the Mac mangles it, but toysh
8# should let us go back to just this when it's available...
9#   echo -n "$€��" > chars
10echo -ne "\x24\xe2\x82\xac\xf0\x90\x90\xb7" > chars
11
12#testing "name" "command" "result" "infile" "stdin"
13
14testing "" "iconv chars | xxd -p" "24e282acf09090b7\n" "" ""
15testing "-t UTF-16BE" "iconv -t UTF-16BE chars | xxd -p" "002420acd801dc37\n" "" ""
16testing "-t UTF-16LE" "iconv -t UTF-16LE chars | xxd -p" "2400ac2001d837dc\n" "" ""
17testing "-t UTF-32BE" "iconv -t UTF-32BE chars | xxd -p" "00000024000020ac00010437\n" "" ""
18testing "-t UTF-32LE" "iconv -t UTF-32LE chars | xxd -p" "24000000ac20000037040100\n" "" ""
19