utf-8 in text

This commit is contained in:
Vitor Santos Costa 2017-09-03 00:15:04 +01:00
parent b2a30b0a53
commit 22c0cbeca3
3 changed files with 8 additions and 4 deletions

View File

@ -138,7 +138,8 @@ int Yap_open_buf_read_stream(const char *buf, size_t nchars, encoding_t *encp,
sno = GetFreeStreamD();
if (sno < 0)
return (PlIOError(RESOURCE_ERROR_MAX_STREAMS, TermNil,
return (PlIOError(RESOURCE_ERROR_MAX_STREAMS,
TermNil,
"new stream not available for open_mem_read_stream/1"));
st = GLOBAL_Stream + sno;
if (encp)

View File

@ -254,7 +254,10 @@ void Yap_DefaultStreamOps(StreamDesc *st) {
return;
}
st->stream_wputc = put_wchar;
st->stream_wgetc = get_wchar_UTF8;
if (st->encoding == ENC_ISO_UTF8)
st->stream_wgetc = get_wchar_UTF8;
else
st->stream_wgetc = get_wchar;
st->stream_putc = FilePutc;
st->stream_getc = PlGetc;
if (st->status & (Promptable_Stream_f)) {

View File

@ -1353,8 +1353,8 @@ static Int style_checker(USES_REGS1) {
Term Yap_BufferToTerm(const unsigned char *s, size_t len, Term opts) {
Term rval;
int sno;
encoding_t L;
sno = Yap_open_buf_read_stream((char *)s, len, &L, MEM_BUF_USER);
encoding_t l = ENC_ISO_UTF8;
sno = Yap_open_buf_read_stream((char *)s, len, &l, MEM_BUF_USER);
rval = Yap_read_term(sno, opts, false);
Yap_CloseStream(sno);