extern char *chxj_rencoding(
request_rec *r,
const char *src,
- apr_size_t *len);
+ apr_size_t *len,
+ const char *enc);
extern char *chxj_encoding_parameter(
request_rec *r,
/*--------------------------------------------------------------------------*/
int color;
char* emoji_type;
+ char* output_encoding; /* Output encoding */
};
typedef struct device_table_list_t device_table_list;
dst = s_convert_img_tag(r, dst, len, cookie);
dst = s_convert_form_tag(r, dst, len, cookie);
- result = chxj_rencoding(r, dst, len);
+ result = chxj_rencoding(r, dst, len, NULL);
DBG(r, "REQ[%X] end chxj_cookie_only_mode()", TO_ADDR(r));
return result;
}
char *
-chxj_rencoding(request_rec *r, const char *src, apr_size_t *len)
+chxj_rencoding(request_rec *r, const char *src, apr_size_t *len,const char *enc)
{
char *obuf;
char *ibuf;
DBG(r,"REQ[%X] end chxj_rencoding()", (unsigned int)(apr_size_t)r);
return ibuf;
}
- DBG(r,"encode convert [%s] -> [%s]", "CP932", entryp->encoding);
-
+ char *from_enc = enc;
+ if (!enc){
+ from_enc = "CP932";
+ }
+ if (strcasecmp(enc,"Shift_JIS") == 0){
+ from_enc = "CP932";
+ }
+ DBG(r,"encode convert [%s] -> [%s]", from_enc, entryp->encoding);
memset(obuf, 0, olen);
- cd = iconv_open(entryp->encoding, "CP932");
+ cd = iconv_open(entryp->encoding, from_enc);
if (cd == (iconv_t)-1) {
if (EINVAL == errno) {
ERR(r, "The conversion from %s to %s is not supported by the implementation.", "CP932", entryp->encoding);
ixhtml10.entryp = entryp;
ixhtml10.cookie = cookie;
+ if (strcasecmp(spec->output_encoding,"UTF-8") == 0 ){
+ apr_table_setn(r->headers_out,HTTP_X_CHXJ_SET_CONTENT_TYPE,"application/xhtml+xml; charset=UTF-8");
+ }
chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "application/xhtml+xml; charset=Shift_JIS"));
/*--------------------------------------------------------------------------*/
r = doc->r;
DBG(r, "REQ[%X] start s_ixhtml10_start_html_tag()", (unsigned int)(apr_size_t)r);
- W_L("<?xml version=\"1.0\" encoding=\"Shift_JIS\" ?>");
+ W_L("<?xml version=\"1.0\" encoding=\"");
+ W_V(ixhtml10->spec->output_encoding);
+ W_L("\" ?>");
W_NLCODE();
W_L("<!DOCTYPE html PUBLIC \"-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.0) 1.0//EN\" \"i-xhtml_4ja_10.dtd\">");
W_NLCODE();
jxhtml.entryp = entryp;
jxhtml.cookie = cookie;
-
+ if (strcasecmp(spec->output_encoding,"UTF-8") == 0 ){
+ apr_table_setn(r->headers_out,HTTP_X_CHXJ_SET_CONTENT_TYPE,"application/xhtml+xml; charset=UTF-8");
+ }
chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "application/xhtml+xml; charset=Windows-31J"));
/*--------------------------------------------------------------------------*/
r = doc->r;
DBG(r, "REQ[%X] start s_jxhtml_start_html_tag()", TO_ADDR(r));
- W_L("<?xml version=\"1.0\" encoding=\"Shift_JIS\" ?>");
+ W_L("<?xml version=\"1.0\" encoding=\"");
+ W_V(jxhtml->spec->output_encoding);
+ W_L("\" ?>");
W_NLCODE();
W_L("<!DOCTYPE html PUBLIC \"-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN\" \"xhtml-basic10-plus.dtd\">");
W_NLCODE();
dt->color = 256;
dt->dpi_width = 96;
dt->dpi_heigh = 96;
+ dt->output_encoding = "Shift_JIS";
for (child = qs_get_child_node(doc,node);
child ;
dt->emoji_type = apr_pstrdup(p, qs_get_node_value(doc, ch));
}
break;
+ case 'o':
+ case 'O':
+ if (strcasecmp(name, "output_encoding") == 0) {
+ Node *ch = qs_get_child_node(doc, child);
+ if (ch && strcasecmp(qs_get_node_name(doc,ch), "text") == 0){
+ dt->output_encoding = apr_pstrdup(p, qs_get_node_value(doc, ch));
+ }
+ }
+ break;
default:
break;
}
/*--------------------------------------------------------------------------*/
.color = 15680000,
.emoji_type = NULL,
+ .output_encoding = "Shift_JIS",
};
int
spec->html_spec_type = CHXJ_SPEC_Jxhtml;
}
}
+ else if (STRCASEEQ('o','O',"output_encoding",k)){
+ spec->output_encoding = apr_pstrdup(r->pool,val);
+ }
}
}
xhtml.entryp = entryp;
xhtml.cookie = cookie;
+ if (strcasecmp(spec->output_encoding,"UTF-8") == 0 ){
+ apr_table_setn(r->headers_out,HTTP_X_CHXJ_SET_CONTENT_TYPE,"text/html; charset=UTF-8");
+ }
chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* Add XML Declare */
/*--------------------------------------------------------------------------*/
- W_L("<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>");
+ W_L("<?xml version=\"1.0\" encoding=\"");
+ W_V(xhtml->spec->output_encoding);
+ W_L("\"?>");
W_NLCODE();
/*--------------------------------------------------------------------------*/
/* Add DocType */
}
if (!r->header_only) {
+
if ((entryp->action & CONVRULE_COOKIE_ONLY_BIT) && cookie) {
dst = chxj_cookie_only_mode(r, *src, (apr_size_t *)len, cookie);
}
}
}
}
+ if (*len > 0){
+ if (strcasecmp(spec->output_encoding,"UTF-8") == 0){
+ dst = chxj_iconv(r,r->pool,dst,len,"CP932","UTF-8");
+ }
+ }
+
+
ap_set_content_length(r, *len);
if (*len == 0) {
}
+
DBG(r, "REQ[%X] end of chxj_convert()", (unsigned int)(apr_size_t)r);
return dst;
dlen = strlen(value);
DBG(r, "************ before encoding[%s]", value);
- dvalue = chxj_rencoding(r, value, &dlen);
+ dvalue = chxj_rencoding(r, value, &dlen,spec->output_encoding);
dvalue = chxj_url_encode(r->pool, dvalue);
DBG(r, "************ after encoding[%s]", dvalue);
if (name && *name != 0) {
name = chxj_url_decode(r->pool, name);
dlen = strlen(name);
- dname = chxj_rencoding(r, name, &dlen);
+ dname = chxj_rencoding(r, name, &dlen,spec->output_encoding);
dname = chxj_url_encode(r->pool, dname);
}
else {
if (value && *value != 0) {
value = chxj_url_decode(pool, value);
dlen = strlen(value);
- dvalue = chxj_rencoding(r, value, &dlen);
+ dvalue = chxj_rencoding(r, value, &dlen,spec->output_encoding);
dvalue = chxj_url_encode(pool, dvalue);
}
else {
if (name && *name != 0) {
name = chxj_url_decode(pool, name);
dlen = strlen(name);
- dname = chxj_rencoding(r, name, &dlen);
+ dname = chxj_rencoding(r, name, &dlen,spec->output_encoding);
dname = chxj_url_encode(pool, dname);
}
else {
dlen = strlen(value);
value = chxj_url_decode(pool, value);
- dvalue = chxj_rencoding(r, value, &dlen);
+ dvalue = chxj_rencoding(r, value, &dlen,spec->output_encoding);
dvalue = chxj_url_encode(pool,dvalue);
result = apr_pstrcat(pool, result, &name[8], "=", dvalue, NULL);
}
if (dlen) {
value = chxj_url_decode(pool, value);
- dvalue = chxj_rencoding(r, value, &dlen);
+ dvalue = chxj_rencoding(r, value, &dlen,spec->output_encoding);
dvalue = chxj_url_encode(pool,dvalue);
if (r->args && strlen(r->args) > 0) {
r->args = apr_pstrcat(pool, r->args, "&", &name[sizeof(CHXJ_QUERY_STRING_PARAM_PREFIX)-1], "=", dvalue, NULL);
dlen = strlen(value);
if (dlen && value) {
value = chxj_url_decode(pool, value);
- dvalue = chxj_rencoding(r, value, &dlen);
+ dvalue = chxj_rencoding(r, value, &dlen,spec->output_encoding);
dvalue = chxj_url_encode(pool,dvalue);
if (r->args && strlen(r->args) > 0) {
r->args = apr_pstrcat(pool, r->args, "&", &name[sizeof(CHXJ_QUERY_STRING_PARAM_PREFIX_ENC)-1], "=", dvalue, NULL);