HtmlEncode UTF-8 - unicode

I'm using Server.HtmlEncode on a utf-8 string in asp-classic, which works fine until there are some accents in the string e.g. Rüstü Recber, which appears as Rüstü Recber (Rüstü Recber in the source).
I've tried setting the Response.Charset property to utf-8 but this doesn't make any difference.

Update (Solved): Adding <%#CODEPAGE=65001%> at the start of the page corrected the problem (http://technet.microsoft.com/en-us/library/bb742422.aspx)
Many thanks for all of the suggestions.

Check if the editor you are using to view the text is set to show utf-8.

Did you try to UrlEncode as well?

Are you sure that the string is correct before it is passed to HtmlEncode ? It looks like the string might be encoded wrong before it is passed to HtmlEncode.
Try to encode a string that you know is correct, and see if it is encoded correctly.

Related

WebElement.getText() function and utf8

May i assume that for every web page the WebElement.getText() function does return utf8 Strings, or can it have other encodings?
If there could be other encodings, how can i identify it and convert it to utf8?
I don't know no one good way(maybe if you like reflection, you can hack and rewrite) to do getText() return needed encoding.
But in this
Selenium web driver and multillanguage
I wrote some way to encode String.
I don't think so. According to the API, getText() returns a String. You will have to find the encoding of that from the page headers.

Zend form Label does not render with accents

I am trying to render a form which contains accents in the setlabel method like:
$ticketNumber->setLabel("Endereço");
I have tried every single option out there from forums. but it does not work, it displays the &atilde instead of the true value of that entity.
I addition. if i try the following, the text for the label does not render(the label is blank) at all.
$ticketNumber->setLabel("Endereço");
In my application.ini have added the following:
resources.view.encoding = "ISO-8859-1"
I really don't know what is wrong. I've been fighting this for couple of days now.
Any help is welcomed.
thank you.
$ticketNumber->setLabel("Endereço");
is correct. But you're then telling it to use an encoding where ç is not a valid character. You need to switch that to UTF-8 or similar:
resources.view.encoding = "UTF-8"

What kind of encoding is this (not base64)?

Recently, I'm working with an API which has response code similar to this:
P257SIae5AEchhrQy6
I've tried base64 and doesn't seem like it. Any clue? I think it could be some sort of base64 because sometimes it has this ending " VEPJlm/a2cDz9JMY+ignA= " which uses = to fill up space.
edit:
NjFpSYZO7LQByUEhBVWKR6R69DLVKdJxvC+PfsQAvdkADzYl/P257SIae5AEchhrQy6/Gx2FCtHP7ykVmc6kHQRczgq3WF3AvNAHuPsMeXphjWbHGUGyuEz5Jd4QD9xt0UdZVFt/tQW6+l+CkSA3U1CwsV8n787tB+t/XbB42F57k1LpT39OUYTvRS4lbnq3
It may not be any encoding. Just a unique id.
It is probably Base64 encoded binary data.
Is this over a serial line? May be a mismatched baudrate, parity, data/stop bit or flow control handshake problem.

Handling special charaters æ,ø,å in objective c - iphone

I have a UILabel which I change through the code. However when I create a NSString with the charaters æ,ø,å(Danish) I get an input conversion warning. The code look as this:
NSString *label=[[NSString alloc]initWithFormat:#"Prøv igen"];
And the warning I get is this - warning: input conversion stopped due to an input byte that does not belong to the input codeset UTF-8. I can understand that ø is probably not an UTF encoding but what to do? Anyone who can give me a hint about what to do to solves this?
Regards
Bjarke
Your source code is not saved as UTF-8, but most likely as something like ISO-8859-1.
Just open the file and re-save it as UTF-8 - and while you're at it, you should probably also make that the default. Exactly how to do that depends on what editor you're using.
Make sure your file text encoding is set to UTF-8, not Western (ISO) or something else. You can use the Xcode file info inspector to do this.
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/XcodeWorkspace/050-File_Management/file_management.html%23//apple_ref/doc/uid/TP40002677-BABICEHI
Make sure it says Unicode (UTF-8) for the File Encoding. If it asks you, tell it to reinterpret your file with the new encoding. Also, you may want to delete the problematic text and reinput it to get it to work.
I had the same problem, but my source code files were already UTF-8 encoded so I fix it in a different way.
In your case, it would have been something like
NSString *label=[NSString stringWithUTF8String"Prøv igen"];
I hope this will be helpful for others who stumble on this question

Encoding problem classic ASP

I have a problem with classic ASP. The encoding is wrong when I send data with XMLHttp.send. The response is a PDF file, but the “ÆØÅ” gets wrong, the “Ø” is read as “øy” for example. It’s like it’s a converting mistake from UTF-8 to ISO-8859-1, but it should be ISO-8859-1 now. I have <%#CODEPAGE="28591"%> at the top at the page and ISO-8859-1 as encoding in the XML file, I have checked the file so it’s valid ISO-8859-1. I don’t have access to the server I am sending this data to, but I fixed it in a VB6 program which use the same logic with:
aPostBody = StrConv(strBody, vbFromUnicode)
WinHttpReq.SetTimeouts 100000, 100000, 100000, 1000000
WinHttpReq.Send aPostBody
And in a C# program that also uses the same logic with
// ISO-8859-1
byte[] bytes = Encoding.GetEncoding(28591).GetBytes(data);
But in ASP classic I need some help to find a way to change the encoding on a string to ISO-8859-1.
Try:
Session.CodePage = 28591
There is some good information here, and I got the CodePage number here.
Have you tried using Response.Charset and setting it like so:
<% Response.Charset="ISO-8859-1"%>
Check the encoding of the .ASP file and all the .ASP files included with #include.
Once I had a problem when I created a new .ASP file in VS and was encoding in UTF-8. This file was included by others, and the file encoding "overwrites" all other encoding commands.
AFAIK this is a known problem with WinHttpReq / XMLHTTPRequest, hope someone proves me wrong.
Reference this as well: How do I set the character set using XMLHttp Object for a POST in classic ASP?
I have used this component both on ASP and Javascript, but on javascript I found the resolution for this issue here: http://squio.nl/blog/2006/06/27/xmlhttprequest-and-character-encoding/
The solution:
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8
Complete:
https://pt.stackoverflow.com/questions/80886/encoding-asp-cl%C3%A1ssico/81418#81418
Have you tried using the meta tag equivalent to what you are doing?
Example:
Response.Write("<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />")
Note: I use a Response.Write to paste spit out the charset, because Visual Studio will attempt to save the file with a different encoding if, for example, the charset is UTF-8.