# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
# echo without interpretation of backslash escapes and without
# adding newline at the end - just the string as it is
rawprint()
{
printf '%s' "$@"
}
encode_dword()
{
printf '\x%02x' \
`expr $1 / 16777216 % 256` \
`expr $1 / 65536 % 256` \
`expr $1 / 256 % 256` \
`expr $1 % 256`
}
encode_string()
{
# turn string into UTF-16 and hexdump it
hex_utf16=`rawprint "$1" | iconv -t UTF-16BE | od -t x1 -A n | tr -d -c '[:xdigit:]'`;