diff options
author | Ito Hiroyuki <ZXB01226@nifty.com> | 2010-08-24 10:11:51 +0000 |
---|---|---|
committer | Ito Hiroyuki <ZXB01226@nifty.com> | 2010-08-24 10:11:51 +0000 |
commit | 919adb4b57977d5e375dab0fa943b6e81fa145ab (patch) | |
tree | 426c3d8d7682ff359f73a136ba0942c35a8f9117 /libwc/ucs.c | |
parent | Introduce option mailto_options (diff) | |
download | w3m-919adb4b57977d5e375dab0fa943b6e81fa145ab.tar.gz w3m-919adb4b57977d5e375dab0fa943b6e81fa145ab.zip |
[w3m-dev 04393] [patch] locale-related character management
Diffstat (limited to '')
-rw-r--r-- | libwc/ucs.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libwc/ucs.c b/libwc/ucs.c index 3645456..d7b6948 100644 --- a/libwc/ucs.c +++ b/libwc/ucs.c @@ -23,6 +23,11 @@ #include "map/ucs_precompose.map" #include "map/ucs_hangul.map" #include "map/ucs_fullwidth.map" +#include "map/ucs_isalpha.map" +#include "map/ucs_isdigit.map" +#include "map/ucs_islower.map" +#include "map/ucs_isupper.map" +#include "map/ucs_case.map" #define MAX_TAG_MAP 0x100 static int n_tag_map = 0; @@ -108,6 +113,8 @@ wc_any_to_ucs(wc_wchar_t cc) f = WC_CCS_INDEX(cc.ccs); switch (WC_CCS_TYPE(cc.ccs)) { case WC_CCS_A_CS94: + if (cc.ccs == WC_CCS_US_ASCII) + return cc.code; if (f < WC_F_ISO_BASE || f > WC_F_CS94_END) return WC_C_UCS4_ERROR; map = cs94_ucs_map[f - WC_F_ISO_BASE]; @@ -558,6 +565,74 @@ wc_is_ucs_hangul(wc_uint32 ucs) ucs_hangul_map, N_ucs_hangul_map) != NULL); } +wc_bool +wc_is_ucs_alpha(wc_uint32 ucs) +{ + return (ucs <= WC_C_UCS2_END && + wc_map_range_search((wc_uint16)ucs, + ucs_isalpha_map, N_ucs_isalpha_map) != NULL); +} + +wc_bool +wc_is_ucs_digit(wc_uint32 ucs) +{ + return (ucs <= WC_C_UCS2_END && + wc_map_range_search((wc_uint16)ucs, + ucs_isdigit_map, N_ucs_isdigit_map) != NULL); +} + +wc_bool +wc_is_ucs_alnum(wc_uint32 ucs) +{ + return (wc_is_ucs_alpha(ucs) || wc_is_ucs_digit(ucs)); +} + +wc_bool +wc_is_ucs_lower(wc_uint32 ucs) +{ + return (ucs <= WC_C_UCS2_END && + wc_map_range_search((wc_uint16)ucs, + ucs_islower_map, N_ucs_islower_map) != NULL); +} + +wc_bool +wc_is_ucs_upper(wc_uint32 ucs) +{ + return (ucs <= WC_C_UCS2_END && + wc_map_range_search((wc_uint16)ucs, + ucs_isupper_map, N_ucs_isupper_map) != NULL); +} + +wc_uint32 +wc_ucs_toupper(wc_uint32 ucs) +{ + wc_map *conv = NULL; + if (ucs <= WC_C_UCS2_END) + conv = wc_map_search((wc_uint16)ucs, + ucs_toupper_map, N_ucs_toupper_map); + return conv ? (wc_uint32)(conv->code2) : ucs; +} + +wc_uint32 +wc_ucs_tolower(wc_uint32 ucs) +{ + wc_map *conv = NULL; + if (ucs <= WC_C_UCS2_END) + conv = wc_map_search((wc_uint16)ucs, + ucs_tolower_map, N_ucs_tolower_map); + return conv ? (wc_uint32)(conv->code2) : ucs; +} + +wc_uint32 +wc_ucs_totitle(wc_uint32 ucs) +{ + wc_map *conv = NULL; + if (ucs <= WC_C_UCS2_END) + conv = wc_map_search((wc_uint16)ucs, + ucs_totitle_map, N_ucs_totitle_map); + return conv ? (wc_uint32)(conv->code2) : ucs; +} + wc_uint32 wc_ucs_precompose(wc_uint32 ucs1, wc_uint32 ucs2) { |