encoding

Garbled characters in cookie

I store Chinese characters in cookie but the cookie value changes to garbled characters. What should I do? function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 1000 * 60 * 60 * 24)); var expires = "; expires=" + date.toGMTString(); } else ...

Creating a ISO-8859-1 string from a HEX-string in Java, shifting bits.

Hello experts! I am trying to convert a HEX-sequence to a String encoded in either, ISO-8859-1, UTF-8 or UTF-16BE. That is, I have a String looking like: "0422043504410442" this represents the characters: "Test" in UTF-16BE. The code I used to convert between the two formats was: private static String hex2String(String hex, String enc...

Decoding HTML entities in Emacs/Elisp

Some online websites like to encode all their text through HTML entities, so instead of seeing a text like So I'm looking You get something like: So I'm looking  I was wondering if there's a built in way to translate the encoded text to regular text using any Emac...

Encoding value in a textbox and passing it to next page

I have a requirement in Classic ASP, I am using a txtbox to store a numeric variable then i am passing it to next page to be passed to stored procedure. Now i am facing XSS issues so i want to encode the value of text box on parent page and then use it on the other page. I know the stored procedure will not run after getting the encode...

Updating Twitter Status

I'm trying to add some twitter funcionality to my website (php). I publish links like http://twitter.com/home?status=Hello World When the twitter page loads, the text box appears with the text Hello%20World That is, with the text url-encoded. I suppose that it's related with the encoding of the page (actually, windows-1252) b...

QDir and QDirIterator ignore files with non-ASCII filenames

The following code somehow fails to notice any files with non-ASCII characters in their names (Cyrillic characters, specifically): for (int path = 1; path < argc; path++) { QFileInfo fi(argv[path]); if (fi.isDir()) { QDir dir(argv[path], "", QDir::LocaleAware, QDir::AllEntries); qDebug() << dir.entryList(); QDirIterator ...

utf-8 decoding in java

I'm trying to pass parameters from a PHP middle tier to a java backend that understands J2EE. I'm writing the controller code in Groovy. In there, I'm trying to decode some parameter that will likely contain international characters. I am really puzzled by the results of my debugging this problem so far, hence I wanted to share it with ...

Why do I get this error when I try to print something in Putty?

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 38: ordinal not in range(128) I am downloading a website and then printing its contents...simple. Do I have to encode it somehow? ...

C# call to unmanaged C++ returning string of squares symbols

I have some C# code calling into an unmanaged C++ DLL. The method I am calling is intended to accept a string as a ref. To handle this I pass in a StringBuilder, otherwise there is a StackOverflowException. This is working fine, but on some calls the string that comes back from the unmanaged code is a jumbled string like this: øŸE˜.,Ê...

Using special Chars in Firefox and IE, are being encoded by the browser differently

Hi guys, I've got a multilingual site, that allows users to input text to search a form field, but the text goes through Javascript before heading off to the backend. Special chars like "欢" are being properly handled in Firefox, but not in any version of IE. Can someone help me understand what's going on? Thanks! ...

I can't change HTTP request header Content-Type value using jQuery

Hi I tried to override HTTP request header content by using jQuery's AJAX function. It looks like this $.ajax({ type : "POST", url : url, data : data, contentType: "application/x-www-form-urlencoded;charset=big5", beforeSend: function(xhr) { xhr.setRequestHeader("Accept-Charset","big5"); xhr.setRequestHeader("Content-Typ...

Does a pronounceable encoding exist ?

I am using UUIDs, but they are not particularly nice to read, write and communicate. So I would like to encode them. I could use base64, or base32, but they would not be easy anyway: base64 has capitalized letters and symbols. Base32 is a bit better, but you can still obtain clumsy stuff. I was wondering if there's a nice and clean way ...

How to encode Video from Web-Camera into H.264 in C# ?

How to encode Video from Web-Camera into H.264 in C# ? What do I need MSDN if thare is any help on this. Open Source Libs/wrappers for encoding/decoding. Tutorials and blog articles on How to do it. Some examples of of how to encode into 3GP or FLV or some thing else (whith low size) would be more than apriciated!))) ...

delphi html decode

Hi, I'm using Delphi 2009 and want to decode an HTML encoded string, for example: &#39; -> ' But cannot find any built in function for doing this. Thanks in advance ...

Converting accented characters in PostgreSQL?

Is there an existing function to replace accented characters with unadorned characters in PostgreSQL? Characters like å and ø should become a and o respectively. The closest thing I could find is the translate function, given the example in the comments section found here. Some commonly used accented characters can be searched us...

.NET character encoding problems

I've got some problems on a .NET site where both Latin (åäö) and Latvian (āē) characters would need to co-exist. In the database, I'm using nvarchar and ntext for my fields, and if I enter the texts directly into the database, everything works fine. The problem is when I enter the exact same text using a form that does an SQL UPDATE, t...

How can I convert an XML document from Latin-1 to UTF-8 in Perl?

We at the company want to convert all the sites we are hosting from Latin-1 to UTF-8. After a ot of googling, we have our Perl script almost complete. The only thing that is missing now are the XML files. What is the best way to convert XML from Latin-1 to UTF-8 and is it useful? I am asking because we are unsure about it since most en...

HTML Encoding Form Post

A user has sent me some information that they posted to one of my pages with potential XSS issues however, looking at the server side code I don't think it would ever run through my code smoothly. They said they sent this: forminfo=%27+%7C%7C+%27%27+%7C%7C+%27%25booleantest%3Atrue%2Ctrue%2Ctrue I have looked at this and have worked o...

Byte Array to String

I'm playing with bencoding and i would like to keep bencoded strings as java strings but they contain binary data blindly converting them to string will corrupt the data. What i am trying to accomplish is have a conversion function that will keep the ascii bytes as ascii end encode non ascii chars in a reversible way. I have found some ...

Encode quotes in HTML body?

Should I encode quotes (such as " and ' -> &rdquo; and &rsquo;) in my HTML body (e.g. convert <p>Matt's Stuff</p> to <p>Matt&rsquo;s Stuff</p>)? I was under the impression I should, but a co-worker said that it was no big deal. I'm dubious but I can't find anything that says it is verboten. Am I mistaken? Is it a best-practice to encode?...