diff --git a/source/texk/ptexenc/ptexenc.c b/source/texk/ptexenc/ptexenc.c index 602b7f866..aa5b9bbc8 100644 --- a/source/texk/ptexenc/ptexenc.c +++ b/source/texk/ptexenc/ptexenc.c @@ -935,4 +935,138 @@ int nkf_close(FILE *fp) { } return fclose(fp); } + + +unsigned char *ptenc_from_utf8_string_to_internal_enc(const unsigned char *is) +{ + int i; + long u = 0, j, len; + int i1 = EOF, i2 = EOF, i3 = EOF, i4 = EOF; + unsigned char *buf, *buf_bak; + long first_bak, last_bak; + + if (terminal_enc != ENC_UTF8 || is_internalUPTEX()) return NULL; + buf_bak = buffer; + first_bak = first; + last_bak = last; + + len = strlen(is)+1; + buffer = buf = xmalloc(len); + first = last = 0; + + for (i=0; i=len) buffer = xrealloc(buffer, len=last+64); + write_hex(i1); + if (i2 != '\0') write_hex(i2); + if (i3 != '\0') write_hex(i3); + if (i4 != '\0') write_hex(i4); + } else { + write_multibyte(j); + } + i2 = i3 = i4 = '\0'; + } + buffer[last] = '\0'; + end: + buffer = buf_bak; + first = first_bak; + last = last_bak; + return buf; +} + +unsigned char *ptenc_from_internal_enc_string_to_utf8(const unsigned char *is) +{ + int i; + long u = 0, len; + int i1 = EOF, i2 = EOF; + unsigned char *buf, *buf_bak; + long first_bak, last_bak; + + if (terminal_enc != ENC_UTF8 || is_internalUPTEX()) return NULL; + buf_bak = buffer; + first_bak = first; + last_bak = last; + + len = strlen(is)+1; + buffer = buf = xmalloc(len*1.5); + first = last = 0; + + for (i=0; i