Which string type for text that goes to a web page?

Go down

Which string type for text that goes to a web page?

· #1

My program builds HTML and sends it over HTTP. With {$H+} everything is AnsiString, and the text is UTF-8 from the database.

Do I gain anything by moving to UnicodeString, or is UTF-8 in AnsiString the simple and right answer here?

Re: Which string type for text that goes to a web page?

· #2

UTF-8 in AnsiString all the way is the simple answer when the input and the output are both UTF-8. Convert only at the edges that need another encoding.

Read the error message. Then read it again.

Re: Which string type for text that goes to a web page?

· #3

Agreed. The one trap is Length and Copy: they count bytes. Cutting a string in the middle of a character gives you a broken page.

Re: Which string type for text that goes to a web page?

· #4

That is the bug I had last month. Good to know why.

Go up

Sign in to reply