Home > Back-end >  Why use idhttp get to the site, use utf8toAnsi after conversion, or some special characters garbled
Why use idhttp get to the site, use utf8toAnsi after conversion, or some special characters garbled

Time:09-19

Although most of the Chinese have to work out, but there are several gibberish,
How to change 54936 to 65001, will complete the UTF8 displayed

But I don't think in this way, go directly and other way can not appear small garbled??

 

IdHTTP1:=TIdHTTP. Create;
Ss:=TStringStream. Create (' ', TEncoding. GetEncoding (54936));//by default gb18030
Idhttp1. Get (' www.jobui.com ', ss);//arbitrary UTF8 sites are so
Memo1. Text:=LowerCase (ss) DataString);//turn out unified all lowercase characters

Memo2. Text:=utf8toAnsi (Memo1. Text);


CodePudding user response:

 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=Utf8ToAnsi (IdHTTP1. Get (' http://www.jobui.com '));
The finally
IdHTTP1. Free;
end;



So did not find the code,

CodePudding user response:

reference 1st floor pathletboy response:
 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=Utf8ToAnsi (IdHTTP1. Get (' http://www.jobui.com '));
The finally
IdHTTP1. Free;
end;



So did not find the code,


Upstairs brother, you try the 2010 edition, was all gibberish

CodePudding user response:

refer to the second floor cowboooo response:
Quote: refer to 1st floor pathletboy response:

 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=Utf8ToAnsi (IdHTTP1. Get (' http://www.jobui.com '));
The finally
IdHTTP1. Free;
end;



So did not find the code,


Upstairs brother, you try the 2010 version, all the code

After 2007 (not including), including control the default encoding is unicode, you turn, nature is garbled,

CodePudding user response:

That is to say, after 2007 (excluding), according to the unicode encoding, can be directly below

 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=IdHTTP1. Get (' http://www.jobui.com ');
The finally
IdHTTP1. Free;
end;

CodePudding user response:

reference 4 floor pathletboy response:
that is to say, after 2007 (excluding), according to the unicode encoding, can be directly below

 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=IdHTTP1. Get (' http://www.jobui.com ');
The finally
IdHTTP1. Free;
end;

It can be, but encounter GB2312 page, display will stil..

CodePudding user response:

refer to 6th floor cowboooo response:
Quote: refer to 4th floor pathletboy response:

That is to say, after 2007 (excluding), according to the unicode encoding, can be directly below

 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=IdHTTP1. Get (' http://www.jobui.com ');
The finally
IdHTTP1. Free;
end;

It can be, but encounter GB2312 page, display will stil..


refer to 6th floor cowboooo response:
Quote: refer to 4th floor pathletboy response:

That is to say, after 2007 (excluding), according to the unicode encoding, can be directly below

 IdHTTP1:=TIdHTTP. Create; 
Try
Memo1. Text:=IdHTTP1. Get (' http://www.jobui.com ');
The finally
IdHTTP1. Free;
end;

It can be, but encounter GB2312 page, display will stil..


You can be the difference between web page code, then the difference between points,

 IdHTTP1:=TIdHTTP. Create; 
Try
HTML:=IdHTTP1. Get (" http://0512aj.cn ");
If IdHTTP1. Response. CharSet & lt;> Then 'utf-8'
HTML:=AnsiToUtf8 (HTML);
Memo1. Text:=HTML;
The finally
IdHTTP1. Free;
end;

CodePudding user response:

UTF8 turn ANSI is what concept, turn the note that can be installed in the water in UTF8, can't be put in the basket of ANSI, can only be put into the bucket ANSI.
ANSI is only containers of a thing, so different languages have different ANSI. Not the same thing.

CodePudding user response:

Just perfect to solve similar problems:
USES the
IdURI;
.

Respon:=TidURI URLDecode (Http Get (TidURI. URLEncode (URLStr)));

Such URLStr don't need to encode and decode, useful, support the combination of Chinese and western culture, ha ha

CodePudding user response:

references 9 f doloopcn response:
just perfect to solve similar problems:
USES the
IdURI;
.

Respon:=TidURI URLDecode (Http Get (TidURI. URLEncode (URLStr)));

So URLStr shouldn't have to encode and decode, useful, support the combination of Chinese and western culture, ha ha
support,,,,

CodePudding user response:

IdURI in c + + builder how to use?

CodePudding user response:

references 9 f doloopcn response:
just perfect to solve similar problems:
USES the
IdURI;
.

Respon:=TidURI URLDecode (Http Get (TidURI. URLEncode (URLStr)));

So URLStr shouldn't have to encode and decode, useful, support the combination of Chinese and western culture, ha ha

learned

CodePudding user response:

Don't use that IDhttp. There are too many problems
  • Related