improve utf-8
This commit is contained in:
parent
556937195d
commit
b98b09e7de
@ -34,7 +34,7 @@ ex(create) :-
|
||||
LAST_NAME CHAR(20),
|
||||
AGE INT,
|
||||
SEX CHAR(1),
|
||||
INCOME FLOAT )',
|
||||
INCOME FLOAT ) DEFAULT charset=utf8',
|
||||
:= $cursor:execute($sql),
|
||||
close.
|
||||
|
||||
@ -102,5 +102,5 @@ except:-
|
||||
|
||||
customer('João', 'Matos', 40, 'M', 2000).
|
||||
customer('Maria', 'Söderling', 20, 'F', 3000).
|
||||
%customer('毛', '泽东', 44, 'M', 500).
|
||||
%customer('রবীন্দ্রনাথ', 'ঠাকুর', 30, 'M', 8000).
|
||||
customer('毛', '泽东', 44, 'M', 500).
|
||||
customer('রবীন্দ্রনাথ', 'ঠাকুর', 30, 'M', 8000).
|
||||
|
@ -588,29 +588,23 @@ term_to_python(term_t t)
|
||||
case PL_VARIABLE:
|
||||
return NULL;
|
||||
case PL_ATOM:
|
||||
case PL_STRING:
|
||||
{
|
||||
char *s;
|
||||
atom_t at;
|
||||
|
||||
if (!PL_get_atom_chars(t, &s)) {
|
||||
wchar_t *w;
|
||||
size_t len;
|
||||
|
||||
if (!PL_get_atom(t, &at))
|
||||
return NULL;
|
||||
if (!(w = PL_atom_wchars(at, &len)))
|
||||
return NULL;
|
||||
return PyUnicode_FromWideChar(w, len );
|
||||
if (PL_get_atom(t, &at)) {
|
||||
if (at == ATOM_true) return Py_True;
|
||||
if (at == ATOM_false) return Py_False;
|
||||
}
|
||||
if (!PL_get_atom(t, &at)) {
|
||||
if (!PL_get_chars(t, &s, REP_UTF8|CVT_ATOM|CVT_STRING|BUF_DISCARDABLE) ) {
|
||||
return NULL;
|
||||
}
|
||||
if (at == ATOM_true) return Py_True;
|
||||
if (at == ATOM_false) return Py_False;
|
||||
if (proper_ascii_string(s))
|
||||
if (proper_ascii_string(s)) {
|
||||
return PyString_FromStringAndSize(s, strlen(s) );
|
||||
else {
|
||||
PyObject *pobj = PyUnicode_DecodeLatin1(s, strlen(s), NULL);
|
||||
} else {
|
||||
PyObject *pobj = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
|
||||
//fprintf(stderr, "%s\n", s);
|
||||
return pobj;
|
||||
}
|
||||
}
|
||||
@ -621,15 +615,6 @@ term_to_python(term_t t)
|
||||
return NULL;
|
||||
return PyInt_FromLong(j);
|
||||
}
|
||||
case PL_STRING:
|
||||
{
|
||||
char *s;
|
||||
size_t len;
|
||||
|
||||
if (!PL_get_string_chars(t, &s, &len))
|
||||
return NULL;
|
||||
return PyByteArray_FromStringAndSize(s, len);
|
||||
}
|
||||
case PL_FLOAT:
|
||||
{
|
||||
double fl;
|
||||
|
Reference in New Issue
Block a user