Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread AnsiString
Wed, Feb 12 2014 5:47 AMPermanent Link

Matthew Jones

I have a server that uses names and organisations, and must have an 8-bit ANSI
string. It is used for install codes, and I can't have the code require that the
user put in #1345; or similar in their name!

Given that EWB applications are of course proper Unicode, and I talk to my RO
server using UTF8Strings, what options do I have to ensure proper operation?

I'd like the browser to be able to do this if possible, but could send it back to
the Delphi (XE2) server if needed. I just need to be sure that when someone puts in
their name in chinese, or uses a smiley, that they can be show how it will look in
basic ANSI in the browser too. It's not about making sure that it survives a
transition to ANSI, but that any issues in conversion are seen immediately, if you
see what I mean.

/Matthew Jones/
Wed, Feb 12 2014 8:56 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Given that EWB applications are of course proper Unicode, and I talk to
my RO server using UTF8Strings, what options do I have to ensure proper
operation? >>

Just loop through the string and make sure that all of the characters are <=
#255:

function IsAnsiString(const Value: String): Boolean;
var
  I: Integer;
begin
  Result:=True;
  for I:=1 to Length(Value) do
     begin
     if (Value[I] > #255) then
        begin
        Result:=False;
        Break;
        end;
     end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  if (not IsAnsiString(Edit1.Text)) then
     ShowMessage('Invalid characters entered');
end;

<< I'd like the browser to be able to do this if possible, but could send it
back to the Delphi (XE2) server if needed. >>

Due to how browser applications work, you'll probably want to do both.  The
part on the front is just for the end-user, the part on the back is for you.
Wink

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Feb 12 2014 11:29 AMPermanent Link

Matthew Jones

Thanks - that is easy.

/Matthew Jones/
Image