summaryrefslogtreecommitdiff
path: root/i18n
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2000-06-14 20:38:29 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2000-06-14 20:38:29 +0000
commit0551aaf60513a7bda0476650a46c657ce1b3bca8 (patch)
tree7fb45208da27d351e4f5fd3998c0b6b3fd5c3093 /i18n
parent913b2ad191416d6122794a41ed8140b45c9a051e (diff)
downloadlibapr-0551aaf60513a7bda0476650a46c657ce1b3bca8.tar.gz
Add support to ap_xlate_open() for an app to specify that the
charset of the locale is to be used for the source or target charset. At EBCDIC initialization, use the locale charset as one of the pair when setting up the default translation handles for content. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60203 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'i18n')
-rw-r--r--i18n/unix/xlate.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/i18n/unix/xlate.c b/i18n/unix/xlate.c
index a0d4435db..d7f2fa137 100644
--- a/i18n/unix/xlate.c
+++ b/i18n/unix/xlate.c
@@ -63,6 +63,9 @@
#if APR_HAS_XLATE
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
#ifdef HAVE_ICONV_H
#include <iconv.h>
#endif
@@ -81,7 +84,7 @@ struct ap_xlate_t {
#endif
};
-/* get_default_codepage()
+/* get_default_charset()
*
* simple heuristic to determine codepage of source code so that
* literal strings (e.g., "GET /\r\n") in source code can be translated
@@ -92,7 +95,7 @@ struct ap_xlate_t {
* unpacked.
*/
-static const char *get_default_codepage(void)
+static const char *get_default_charset(void)
{
#ifdef __MVS__
#ifdef __CODESET__
@@ -121,6 +124,37 @@ static const char *get_default_codepage(void)
return "unknown";
}
+/* get_locale_charset()
+ *
+ * If possible on this system, get the charset of the locale. Otherwise,
+ * defer to get_default_charset().
+ */
+
+static const char *get_locale_charset(void)
+{
+#if defined(HAVE_NL_LANGINFO) && defined(HAVE_CODESET)
+ const char *charset;
+ charset = nl_langinfo(CODESET);
+ if (charset) {
+ return charset;
+ }
+#endif
+ return get_default_charset();
+}
+
+static const char *handle_special_names(const char *page)
+{
+ if (page == APR_DEFAULT_CHARSET) {
+ return get_default_charset();
+ }
+ else if (page == APR_LOCALE_CHARSET) {
+ return get_locale_charset();
+ }
+ else {
+ return page;
+ }
+}
+
static ap_status_t ap_xlate_cleanup(void *convset)
{
#ifdef HAVE_ICONV
@@ -176,14 +210,9 @@ ap_status_t ap_xlate_open(ap_xlate_t **convset, const char *topage,
int found = 0;
*convset = NULL;
-
- if (!topage) {
- topage = get_default_codepage();
- }
- if (!frompage) {
- frompage = get_default_codepage();
- }
+ topage = handle_special_names(topage);
+ frompage = handle_special_names(frompage);
new = (ap_xlate_t *)ap_pcalloc(pool, sizeof(ap_xlate_t));
if (!new) {