Защо ?
6 отговора
263 прегледа
Защо ?
procedure TForm1.Button1Click(Sender: TObject);
const
char = WideChar(#$3b5);
text = WideString(#$c0#$152 + char + #$7);
var
i: Integer;
begin
for i := 1 to Length(text) do
if char = text[ i] then
Button1.Caption := 'ok';
end;
Защо нямам ОК
Смятах да го пусна в някоя newsgroup-а , но я да видим вашето мнение. Това съм го писал под Делфи 7 и е малко променено спрямо кода, който ми трябва да подкарам.
by Waz Gaa
[email protected]
const
char = WideChar(#$3b5);
text = WideString(#$c0#$152 + char + #$7);
var
i: Integer;
begin
for i := 1 to Length(text) do
if char = text[ i] then
Button1.Caption := 'ok';
end;
Защо нямам ОК
Смятах да го пусна в някоя newsgroup-а , но я да видим вашето мнение. Това съм го писал под Делфи 7 и е малко променено спрямо кода, който ми трябва да подкарам.
by Waz Gaa
[email protected]
Re: Защо ?
pogledni towa:
------------------------------
I got a COMPILER, and I'm not afraid to use it!
procedure TForm1.Button4Click(Sender: TObject);
const
char_ = WideChar(#$3b5);
var
i: Integer;
text_:WideString;
begin
// text_:=widestring('');
// text_:=text_+#$0152#$0122;
text_:=widechar(#$0152)+widestring('')+widechar(#$0122);
// text_:=widestring(#$0152#$0122);
// ShowMessage(IntToHex(word(char_),4));
for i := 1 to Length(text_) do begin
ShowMessage(IntToHex(word(text_[ i]),4));
if char_ = text_[ i] then begin
ShowMessage('ok');
break;
end;
end;
end;
------------------------------
I got a COMPILER, and I'm not afraid to use it!
Re: Защо ?
The Delphi language supports single-byte and multibyte characters and strings through the Char, PChar, AnsiChar, PAnsiChar, and AnsiString types. Indexing of multibyte strings is not reliable, since S[ i] represents the ith byte (not necessarily the ith character) in S.
Затова пък гледай:
procedure TForm1.Button1Click(Sender: TObject);
const
char:WideChar=#$03b5;
var
i: Integer;
text :WideString;
begin
//text:=WideString(#$00c0#$0152)+char+WideString(#$0007);
text:=WideString(#$00c0)+WideString(#$0152)+char+WideString(#$0007);
for i := 1 to Length(text)
do begin
ShowMessage('Ord(Char)='+IntToStr(ord(Char))+' Char=<'+char+'>'#13
+'Ord(Text[ i])='+IntToStr(ord(Text[ i]))+' Text['+IntToStr(i)+']=<'+text[ i]+'>');
if char = text[ i] then Button1.Caption := 'ok';
end;
end;
Затова пък гледай:
procedure TForm1.Button1Click(Sender: TObject);
const
char:WideChar=#$03b5;
var
i: Integer;
text :WideString;
begin
//text:=WideString(#$00c0#$0152)+char+WideString(#$0007);
text:=WideString(#$00c0)+WideString(#$0152)+char+WideString(#$0007);
for i := 1 to Length(text)
do begin
ShowMessage('Ord(Char)='+IntToStr(ord(Char))+' Char=<'+char+'>'#13
+'Ord(Text[ i])='+IntToStr(ord(Text[ i]))+' Text['+IntToStr(i)+']=<'+text[ i]+'>');
if char = text[ i] then Button1.Caption := 'ok';
end;
end;
Редактирано от NDeu на
Re: Защо ?
В твоя пример отново WideString(#$00c0) излиза като превод в кирилица $410
by Waz Gaa
[email protected]
by Waz Gaa
[email protected]
Re: Защо ?
Нещо интересно:
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widestring(#$0c0);
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widechar(#$0c0);
В първия случай ShowMessage дава 410, във втория C0 ?
by Waz Gaa
[email protected]
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widestring(#$0c0);
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widechar(#$0c0);
В първия случай ShowMessage дава 410, във втория C0 ?
by Waz Gaa
[email protected]
Izwod:
WideChar=Char po otnoshenie reshenieto kakaw tip ima rezultata na izraza
i kato sabirash WideChar(s ) spored kompilatora se poluchawa AnsiString kojto sled towa se castwa kam WideString - ama fajdata
Ochewidno kato izpolzwash WideString w izraza - taq greshka ne moje da se poluchi.
-=-=-=-=-=-
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widestring(#$0c0);
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widechar(#$0c0);
В първия случай ShowMessage дава 410, във втория C0 ?
-=-=-=-=-=-
mi typecast kam WideString stava ako e Ansi ergo parwo kam Ansi i posle Wide - pone az taka si mislq


btw mojesh da go postnesh w newsgrupite na borland belkim porazmislqt po waprosa za wide-cast-a
------------------------------
I got a COMPILER, and I'm not afraid to use it!
i kato sabirash WideChar(s ) spored kompilatora se poluchawa AnsiString kojto sled towa se castwa kam WideString - ama fajdata
Ochewidno kato izpolzwash WideString w izraza - taq greshka ne moje da se poluchi.
-=-=-=-=-=-
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widestring(#$0c0);
text_:=widechar(#$0152)+widestring('')+widechar(#$0122)+widechar(#$0c0);
В първия случай ShowMessage дава 410, във втория C0 ?
-=-=-=-=-=-
mi typecast kam WideString stava ako e Ansi ergo parwo kam Ansi i posle Wide - pone az taka si mislq
btw mojesh da go postnesh w newsgrupite na borland belkim porazmislqt po waprosa za wide-cast-a
------------------------------
I got a COMPILER, and I'm not afraid to use it!
Мдаа
Проблем, който не бях забелязал (и който е решен в кода на NDeu).
Ако се мажне WideString('') , Делфи дава грешка !?
by Waz Gaa
[email protected]
var
text: WideString;
begin
text := WideChar(#$0152) + WideString('') + WideChar(#$00c0);
end;
Ако се мажне WideString('') , Делфи дава грешка !?
by Waz Gaa
[email protected]