Archived Forum Post

Index of archived forum posts

Question:

Decode Bulgarian?

Jul 12 '16 at 13:22

Hello, I am a long time user of your ChilkatSoft utilities.

Can you help me with something?

I am trying to figure out if we can decode a % encoded URL string. It’s in European characters and comes from us via a website in Europe.

This is in Bulgarian

For example, we get something like this that a user types into a web page…

(example #1)

котката в шапката се връща

But when that information gets transferred to us… we see it encoded like this…

(example #2)

%D0%BA%D0%BE%D1%82%D0%BA%D0%B0%D1%82%D0%B0+%D0%B2+%D1%88%D0%B0%D0%BF%D0%BA%D0%B0%D1%82%D0%B0+%D1%81%D0%B5+%D0%B2%D1%80%D1%8A%D1%89%D0%B0

I need to know if we can figure out a way to translate this to the Bulgarian characters from the encoded format.

Does your Charset component handle this?


Answer

The solution is to URL decode to bytes, and then interpret the bytes according to the correct character encoding (utf-8, Windows-1251, etc.) to get the string.

It turns out this data is the utf-8 representation of the Bulgarian text.

This is an easy solution in C#:

Chilkat.Crypt2 crypt = new Chilkat.Crypt2();

crypt.CryptAlgorithm = "none"; crypt.EncodingMode = "url"; crypt.Charset = "utf-8";

textBox1.Text = crypt.DecryptStringENC("%D0%BA%D0%BE%D1%82%D0%BA%D0%B0%D1%82%D0%B0+%D0%B2+%D1%88%D0%B0%D0%BF%D0%BA%D0%B0%D1%82%D0%B0+%D1%81%D0%B5+%D0%B2%D1%80%D1%8A%D1%89%D0%B0");