indexdata / yaz

Z39.50 toolkit for C
http://www.indexdata.com/yaz
Other
43 stars 19 forks source link

how to set the charset ? In nodejs, chinese characters are garbled in results whitch returned from some GB2312 servers #64

Closed DitieNoder closed 2 years ago

DitieNoder commented 2 years ago

I come from here , https://github.com/dengelke/node-zoom2/issues/30 ,please look at this . In nodejs , I use a module node-zoom2 whitch compiled from yaz and C . Because Nodejs only support one of utf8, ucs2, ascii, binary, base64, hex , so when the result from server is decoded by GB2312 , the Nodejs progame would explain the results by utf8 immediatly ,therefore the chinese characters go garbled .

1、Could you please support to set the charset when sendding request ? or when the server return results by GB2312-decode, the C progame could encode the results with iso-8859-1(or other method ) in the middle , then the nodejs progame could decode the results from iso-8859-1(or other method ) to utf8 and get the chinese characters to display correctly.

2、could the module support 'cnmarc' ?

thank you for you help

duolaamenggit commented 2 years ago

well,I have the same question ,would someone help us ,thankyou very much!!

adamdickmeiss commented 2 years ago

For ZOOM_record_get, the type parameter is described here: https://software.indexdata.com/yaz/doc/zoom.records.html

Example:

Convert a MARC that is encoded in gb2312 to XML in utf-8:

ZOOM_record_get(rec, "xml;charset=gb2312", &len);
DitieNoder commented 2 years ago

For ZOOM_record_get, the type parameter is described here: https://software.indexdata.com/yaz/doc/zoom.records.html

Example:

Convert a MARC that is encoded in gb2312 to XML in utf-8:

ZOOM_record_get(rec, "xml;charset=gb2312", &len);

Thank you for your guidance.I have two more questions:

1、I do not know how to use the command " ZOOM_record_get() " in nodejs .

2、And the document says " length is stored in *len. ",but in the example you says " &len“ , so are these style of writing all workful ? image image

thank you again

adamdickmeiss commented 2 years ago

For ZOOM_record_get, the type parameter is described here: https://software.indexdata.com/yaz/doc/zoom.records.html Example: Convert a MARC that is encoded in gb2312 to XML in utf-8:

ZOOM_record_get(rec, "xml;charset=gb2312", &len);

Thank you for your guidance.I have two more questions:

1、I do not know how to use the command " ZOOM_record_get() " in nodejs .

I don't know either. Perhaps a question like that should be directed elsewhere.

2、And the document says " length is stored in *len. ",but in the example you says " &len“ , so are these style of writing all workful ? image image

The pointer notation is basic C. I don't know how this is dealt with in the ZOOM node implementation.

thank you again

DitieNoder commented 2 years ago

For ZOOM_record_get, the type parameter is described here: https://software.indexdata.com/yaz/doc/zoom.records.html Example: Convert a MARC that is encoded in gb2312 to XML in utf-8:

ZOOM_record_get(rec, "xml;charset=gb2312", &len);

Thank you for your guidance.I have two more questions: 1、I do not know how to use the command " ZOOM_record_get() " in nodejs .

I don't know either. Perhaps a question like that should be directed elsewhere.

2、And the document says " length is stored in *len. ",but in the example you says " &len“ , so are these style of writing all workful ? image image

The pointer notation is basic C. I don't know how this is dealt with in the ZOOM node implementation.

thank you again

thank you ,it seem that i should lookup another way somewhere .thank you again for your help, good luck~