Re: Unicode or ASCII - perhabs that a problem?



Perhabs the solution for now, even if a bit unsatisfying:

1. I loop over the Tcl_Obj's
2. I get the length of the unicode string with Tcl_GetCharLength
3. I loop over the unicode chars with Tcl_GetUniChar and store each
Tcl_UniChar in a char array
4. I use this char array inside the attached library, which uses fopen

Do somebody have a better solution for tcl 8.4a2 (no upgrade possible
yet)?

Best regards,

Martin Lemburg
UGS - Transforming the Process of Innovation

MartinLemburg@UGS wrote:
Ok - one step back.

Tcl_UniCode returns Tcl_UniChar*, which is an array of "unsigned
short"s.

How can I get the (in the debugger right looking) represented string
(Tcl_UniChar*) to my "normal" char* string?

I tried with Tcl_UniCharToUtfDString, but the Tcl_DString contained
still it scrambled file name, I can not use with fopen.

-----

In this context - please don't ask for using Tcl_Channels, the tcl file
access API, because the library below this Tcl_(Obj)?CmdProc interface
is completely free from any tcl and uses fopen. This is not changable!

-----

Thanks again! I'm happy for every suggestion!

Martin Lemburg
UGS - Transforming the Process of Innovation

MartinLemburg@UGS wrote:
A change or extension of my question!

I found Tcl_UniCode to return the right string - the string I expected
to get (.../binär/somefile).

But now - must I free this unicode string with Tcl_Free?
I know, that I must not free the string represented by the char*
returned from Tcl_GetStringFromObj, but how to care for with the
returned pointer from Tcl_UniCode?

Thanks again,

Martin Lemburg

MartinLemburg@UGS wrote:
Hello,

we extended a tcl shell with some commands written in C++. Those
commands were created a long time ago and uses the Tcl_CmdProc instead
of the Tcl_ObjCmdProc interface.

Now we transfer a file name containing "umlaute" to one of these
commands and suddenly, this file name, this string seems to be
scrambled like:

.../binär/somefile

to

.../binĤr/somefile

Using now fopen on this scrambled file name, causes fopen to fail.

I reworked the tcl commands to use the Tcl_ObjCmdProc, but still
accessing the Tcl_Obj's string representation contains this scrambled
file name.

Is this a conflict between tcl 8.4's Unicode features and the usage of
the strings as normal char*?

Thanks and best regards,

Martin Lemburg
UGS - Transforming the Process of Innovation

.



Relevant Pages

  • Re: need a tiny help with my SWIGd program
    ... what would I be passing as TCL var to this function? ... junk ... char ** means an array of null terminated strings. ... x setitem 0 "string 1" ...
    (comp.lang.tcl)
  • Re: need a tiny help with my SWIGd program
    ... what would I be passing as TCL var to this function? ... char ** means an array of null terminated strings. ... void setitem{ ... x setitem 0 "string 1" ...
    (comp.lang.tcl)
  • Re: CString not working as advertised
    ... with writing a VC++ MFC application that needs to convert some CString ... Note that default for VS 2005 is Unicode, so a quoted string like above is meaningless. ... That's because you are using a Unicode string. ... If you want a char *, ...
    (microsoft.public.vc.mfc)
  • RE: Asking again - ResultSet.getString() & unicode
    ... Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ... I can get the unicode string correctly from sqlserver. ... T-SQL, when we inserting unicode string, it's recommended that we add "N" ...
    (microsoft.public.sqlserver.odbc)
  • Re: need a tiny help with my SWIGd program
    ... what would I be passing as TCL var to this function? ... junk ... char ** means an array of null terminated strings. ... x setitem 0 "string 1" ...
    (comp.lang.tcl)