Home > Archive > Tcl > October 2005 > tcl C API and UTF-8 problems...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
tcl C API and UTF-8 problems...
|
|
| Ben Thomas 2005-10-23, 6:59 pm |
| Hi,
I created a small test command in C which mainly receives a string and
prints the decimal value of it.
My problem is that on some computer, I receive the string in cp1252 (my
system encoding) while on other computer (aslo in cp1252), I receive the
string in UTF-8.
I use tcl 8.4 and from what I read, commands should always receive the
string in UTF-8... I do not know what I do wrong.
Thank you,
Ben.
Here's my code example:
Tcl_CreateCommand (interp, "testCommand", testCommand, NULL, NULL);
....
int testCommand (ClientData clientData, Tcl_Interp* interp, int argc,
const char *argv[]) {
if (!argc) return TCL_ERROR;
char* p = argv[0];
// printf are there for debug purpose; they are not intended to output
valid message in tcl.
while (*p) {
printf ("%d ", *p);
++p;
}
printf ("\n");
return TCL_OK
}
| |
| Ben Thomas 2005-10-23, 9:57 pm |
| Hi again,
Okay, found a part of my problem.
In one computer, writing
encoding name
output lots of encoding, and it is the computer who run the test app
correctly.
On my other computer, it only display those 3 encoding:
utf-8 identity unicode
I would suspect the 2 computers are not set identicaly. Are the encoding
directly build in tcl or are they in external package?
Thank you,
Ben.
Ben Thomas wrote:
> Hi,
>
> I created a small test command in C which mainly receives a string and
> prints the decimal value of it.
>
> My problem is that on some computer, I receive the string in cp1252 (my
> system encoding) while on other computer (aslo in cp1252), I receive the
> string in UTF-8.
>
> I use tcl 8.4 and from what I read, commands should always receive the
> string in UTF-8... I do not know what I do wrong.
>
> Thank you,
> Ben.
>
> Here's my code example:
>
>
>
> Tcl_CreateCommand (interp, "testCommand", testCommand, NULL, NULL);
>
> ...
>
> int testCommand (ClientData clientData, Tcl_Interp* interp, int argc,
> const char *argv[]) {
> if (!argc) return TCL_ERROR;
>
> char* p = argv[0];
>
> // printf are there for debug purpose; they are not intended to
> output valid message in tcl.
> while (*p) {
> printf ("%d ", *p);
> ++p;
> }
> printf ("\n");
>
> return TCL_OK
> }
| |
| suchenwi 2005-10-24, 3:58 am |
| {utf-8 identity unicode} are the hard-wired trivial encodings. Others
are read from the directory
$::tcl_library/encoding/
For instance, for iso8859-1 there would be a file iso8859-1.enc in that
place. The .enc files are plain text, but a bit hard to read. The
format is explained on man Tcl_GetEncoding.
|
|
|
|
|