From c17dc661eae89cea66959fad4fe48d77f1faf174 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 16 Apr 2005 05:09:33 +0000 Subject: [project @ 2005-04-16 05:09:32 by jmb] Split out UTF-8 handling functions. Submit URL-encoded forms in sensible encoding: * First entry in accept-charset list, if present * Document encoding, otherwise We may want to explicitly look for UTF-8, to save converting. Convert cnv_str_local_enc/cnv_local_enc_str to use iconv (they're now veneers for utf8_[to/from]_enc). Provide mechanism for looking up local system charset (derived from system alphabet, under RISC OS) svn path=/import/netsurf/; revision=1647 --- riscos/ucstables.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'riscos/ucstables.c') diff --git a/riscos/ucstables.c b/riscos/ucstables.c index 3dc38e066..b744e9c6a 100644 --- a/riscos/ucstables.c +++ b/riscos/ucstables.c @@ -9,8 +9,10 @@ * UCS conversion tables */ +#include "oslib/osbyte.h" #include "oslib/territory.h" #include "netsurf/riscos/ucstables.h" +#include "netsurf/utils/utils.h" /* Common values (ASCII) */ #define common \ @@ -331,3 +333,42 @@ int *ucstable_from_alphabet(int alphabet) return ucstable; } + +static const char *localencodings[] = { + "ISO-8859-1", /* BFont - 100 - just use Latin1, instead */ + "ISO-8859-1", /* do we want to use Acorn Latin1, instead? */ + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8869-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-IR-182", + "UTF-8", + "ISO-8859-15", + "ISO-8859-10", + "ISO-8859-13", + "ISO-8859-14", + "CP866" /* Cyrillic2 - 120 */ +}; + +/** + * Retrieve local encoding name, suitable for passing to iconv + */ +const char *local_encoding_name(void) +{ + os_error *error; + int alphabet; + + error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &alphabet); + if (!error) { + if (alphabet < 116) + return localencodings[alphabet - 100]; + else if (alphabet == 120) + return localencodings[16]; + } + + return localencodings[0]; +} -- cgit v1.2.3