From: Harald O. <har...@el...> - 2025-04-16 11:35:29
|
Jan, thanks for the hint. I have now replaced it with the idom introduced in Tcl 8.0 (at least Tcl 8.4): Tcl_WinUtfToTChar( pStr, lStr, &sPar1); IMHO this looks nicer, as no #if is required. I suppose, there is an #if under the hood, but it is not visible to me. But I feel, I get again something completly wrong. That is all soooooooooooooo complicated... Why now two commands, where there was one before and a requirement for an #if, where there was none before. The migration: https://core.tcl-lang.org/tcl/wiki?name=Migrating+C+extensions+to+Tcl+9&p does not tell anything on this... Thanks for all, Harald Am 16.04.2025 um 13:05 schrieb Jan Nijtmans: > Op wo 16 apr 2025 om 11:21 schreef Harald Oehlmann: >> Here is the relevant code snippet: >> >> pStr = Tcl_GetStringFromObj(objv[PositionSPar],&lStr); >> Tcl_UtfToExternalDString( NULL, pStr, lStr, &sPar1); >> TextOut(pdlg.hDC, X0, Y0, Tcl_DStringValue( &sPar1 ), Tcl_DStringLength( >> &sPar1 )) > > My recommendation would be to do this: > > #if (TCL_MAJOR_VERSION < 9) /* In case of Tcl 8.6 */ > # define Tcl_UtfToWCharDString Tcl_UtfToUniCharDString > # endif > > pStr = Tcl_GetStringFromObj(objv[PositionSPar],&lStr); > Tcl_DStringInit( &sPar1 ); > Tcl_UtfToWCharDString( pStr, lStr, &sPar1); > TextOutW(pdlg.hDC, X0, Y0, Tcl_DStringValue( &sPar1 ), Tcl_DStringLength( > &sPar1 )/sizeof(WCHAR)); > > That's what Tcl_UtfToWCharDString was meant for, and it > works with any encoding, with or without TIP #716. > > Hope this helps, > Jan Nijtmans |