Updated 2012-12-20 11:01:30 by RLE

I'm trying to write some extension in C. It is intended for reading/writing id3 tags from MP3 files. But problem has raised while developing.

How can i return (for ex) Cyrillic string to TCL interpreter to be shown OK. In C code I have char* filled with my Cyrillic words.

But when i set result of command with

Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));

unknown symbols are shown instead of correct word.

Lars H: This mostly sounds like an encoding problem. Check out http://www.tcl.tk/man/tcl8.4/TclLib/Encoding.htm. You'll probably want to use Tcl_ExternalToUtfDString and then Tcl_DStringResult.

On second thought, if the encoding for these "id3 tags" isn't covered in the file format spec then the best option might be to return the "raw" value as a bytearray (Tcl_NewByteArrayObj) and then write Tcl code that tries to determine the proper encoding conversion to use.