Page 1 of 1

special characters in get box

PostPosted: Tue Sep 06, 2016 6:55 pm
by plantenkennis
Hello,

When I want to show a special character in a get, this does not show the right character. See example
Code: Select all  Expand view
#include "FiveMac.ch"

function Main()

   local oDlg
   local cText1 := "Abelia ×grandiflora", cText2 := "Abelia schumannii 'Bumblebee'", cText3 := "Ceanothus ×delilianus 'Henri Défossé' "
   
   SET DATE FRENCH
   
   DEFINE DIALOG oDlg TITLE "TestGet" SIZE 400, 200 FLIPPED
   
   @ 15, 30 SAY "Text1:" OF oDlg
   
   @ 15, 90 GET cText1 OF oDlg TOOLTIP "a string with cross" SIZE 350, 25

   @ 45, 30 SAY "Text2:" OF oDlg

   @ 45, 90 GET cText2 OF oDlg TOOLTIP "a string with apo" SIZE 350, 25

   @ 75, 30 SAY "Text3:" OF oDlg

   @ 75, 90 GET cText3 OF oDlg TOOLTIP "a normal string" SIZE 350, 25
   
   @ 140, 150 BUTTON "Ok" OF oDlg ACTION MsgInfo( cText1 ), MsgInfo( cText2 ), MsgInfo( cText3 )
   
   ACTIVATE DIALOG oDlg CENTERED
         
return nil

 


But when I get the string from a database, the string is shown good, but I can't get the changed text in a msgbox

Rene

Re: special characters in get box

PostPosted: Wed Sep 07, 2016 7:37 am
by Antonio Linares
Rene,

The GETs look fine here:

Image

Re: special characters in get box

PostPosted: Wed Sep 07, 2016 7:50 am
by Antonio Linares
Rene,

Currently we are using the encoding NSUTF8StringEncoding to retrieve the string parameter:

NSString * hb_NSSTRING_par( int iParam )
{
return [ [ [ NSString alloc ] initWithCString: HB_ISCHAR( iParam ) ? hb_parc( iParam ) : "" encoding: NSUTF8StringEncoding ] autorelease ];
}

These are the possible encoding values:
enum {
NSASCIIStringEncoding = 1,
NSNEXTSTEPStringEncoding = 2,
NSJapaneseEUCStringEncoding = 3,
NSUTF8StringEncoding = 4,
NSISOLatin1StringEncoding = 5,
NSSymbolStringEncoding = 6,
NSNonLossyASCIIStringEncoding = 7,
NSShiftJISStringEncoding = 8,
NSISOLatin2StringEncoding = 9,
NSUnicodeStringEncoding = 10,
NSWindowsCP1251StringEncoding = 11,
NSWindowsCP1252StringEncoding = 12,
NSWindowsCP1253StringEncoding = 13,
NSWindowsCP1254StringEncoding = 14,
NSWindowsCP1250StringEncoding = 15,
NSISO2022JPStringEncoding = 21,
NSMacOSRomanStringEncoding = 30,
NSUTF16StringEncoding = NSUnicodeStringEncoding,
NSUTF16BigEndianStringEncoding = 0x90000100,
NSUTF16LittleEndianStringEncoding = 0x94000100,
NSUTF32StringEncoding = 0x8c000100,
NSUTF32BigEndianStringEncoding = 0x98000100,
NSUTF32LittleEndianStringEncoding = 0x9c000100,
NSProprietaryStringEncoding = 65536
};
typedef NSUInteger NSStringEncoding;

Re: special characters in get box

PostPosted: Wed Sep 07, 2016 7:53 am
by Antonio Linares
This is the MsgInfo() source code:

HB_FUNC( MSGINFO )
{
NSString * msg, * title;

CocoaInit();

ValToChar( hb_param( 1, HB_IT_ANY ) );
msg = hb_NSSTRING_par( -1 );
if( [ msg length ] == 0 )
msg = @" " ;

if( hb_pcount() > 1 )
{
ValToChar( hb_param( 2, HB_IT_ANY ) );
title = hb_NSSTRING_par( -1 );
if( [ title length ] == 0 )
title = @"Attention" ;
}
else
title = @"Attention";

NSAlert * alert = [ [ NSAlert alloc ] init ];

alert.alertStyle = NSInformationalAlertStyle ;
alert.informativeText = msg ;
alert.messageText = title ;

[ alert addButtonWithTitle:@"OK"];
[ alert runModal ];
[ alert release ];

hb_ret();
}

If we change the enconding used in hb_NSSTRING_par(), then the MsgInfo() may look fine

Re: special characters in get box

PostPosted: Sun Sep 11, 2016 3:54 pm
by plantenkennis
Hello Antonio,
Thanks for the reply, but I get to see this on my screen:
Image

Can/must I change the encoding somewhere?

Rene