encoding

Crypto in Ruby and Alphanumeric

Hey, I am working on a project that involves a url "forwarder" (like bit.ly or tinyurl.com, but we don't really need it to be short). For that, I need to "generate" alphanumeric strings (I explicitly want alphanumeric) to map to each url. One of the options would be generate a random string and store it somewhere. However, I'd like to ...

How to change character encoding of XmlReader

I have a simple XmlReader: XmlReader r = XmlReader.Create(fileName); while (r.Read()) { Console.WriteLine(r.Value); } The problem is, the Xml file has ISO-8859-9 characters in it, which makes XmlReader throw "Invalid character in the given encoding." exception. I can solve this problem with adding <?xml version="1.0" encoding="IS...

Adding HTML encoding to the business layer

When adding user input to a web page, it should (unless it's HTML of course :) be encoded to help prevent XSS attacks etc.. like this: litForename.Text = HttpUtility.HtmlEncode(MyUser.Forename); I'm putting together a template to generate my business logic layer, and I'm thinking of using it to do all the encoding as soon as the data ...

Unicode Problem with SQLAlchemy

I know I'm having a problem with a conversion from Unicode but I'm not sure where it's happening. I'm extracting data about a recent Eruopean trip from a directory of HTML files. Some of the location names have non-ASCII characters (such as é, ô, ü). I'm getting the data from a string representation of the the file using regex. If i ...

Mail header fields: Practical difference between quoted-printable and 7bit?

Is there any practical difference between "7bit" and "quoted-printable" as Content-Transfer-Encoding in email? From all I could gather the encoding schemes are virtually identical. ...

What made many of the coding websites converting standard " into non standard ” ?

This question is about standard double quote " and non-standard double quote “ & ” Yesterday when I searched for some sample facebook serverfbml codes, and came upon to this http://mahmudahsan.wordpress.com/2008/11/22/facebook-fbml-rendering-in-iframe-application/ okay so it has got what I want, so I copied the code to my project an...

Detect presence of a specific charset

Hi, I need a way to detect whether a file contains characters from a certain charset. Specifically, I want to detect the presence of UTF8-encoded cyrillic characters in a series of files. Is there a tool to do this? Thanks ...

Encrypted using AES and passing in querystring, will Html.Encode make it work?

I am Encrypted using AES and passing in querystring, will Html.Encode convert all the characters properly such that calling Decode will result in the same string? ...

Are there any problems converting between SHIFT_JIS and Unicode encodings?

I've heard there are (used to be?) ambiguous mappings between Unicode and SHIFT_JIS codes. This KB article somewhat proves this. So the question is: will I lose any data if I take SHIFT_JIS-encoded text, convert it to Unicode and back? Details: I'm talking about Windows (XP and on) and .NET (which in theory relies on NLS API). ...

Why is my JSON which contains HTML causing errors?

My JSON that is being returned from my ASP.NET MVC application looks like this: {code: "1", error: "0", output: "<div class="a1"><div class="b1">this is fasta's</div></div>} It is not working because I am not escaping it properly. I'm not using a JSON library, can someone recommend a function that would clean up my HTML so this works...

Converting document encoding when reading with dom4j

Is there any way I can convert a document being parsed by dom4j's SAXReader from the ISO-8859-2 encoding to UTF-8? I need that to happen while parsing, so that the objects created by dom4j are already Unicode/UTF-8 and running code such as: "some text".equals(node.getText()); returns true. ...

Can't Convert unicode Data into XML column in sql server 2008

Dear All, I already have a table with 3 column (Id bigint, Title nvarchar(450), Description nvarchar(MAX)) in sql 2008 I decide convert Title and Description column into one XML column. but when trying to update get many error like "illegal name character" or "illegal qualified name character" and etc. to solve this problem i just cre...

Python JSON encoding

I'm trying to encode data to JSON in Python and I been having a quite a bit of trouble. I believe the problem is simply a misunderstanding. I'm relatively new to Python and never really got familiar with the various Python data types, so that's most likely what's messing me up. Currently I am declaring a list, looping through and ano...

Partially load large text file with different encodings

I am writing a Java text component, and is trying to partially load some large text file in the middle (for speed reasons). My question is if the text is in some multi-bytes encoding format, like UTF8, Big5, GBK, etc. How can I align the bytes so that I can correctly decode the text? ...

How would I reverse engineer a cryptographic algorithm?

I wrote an application that encrypts text in this way: Get the input text Reverse the text Convert to hexadecimal XOR with a key Base64 encode Now, I didn't do a lot of encryption/encoding myself, so my question might sound stupid, but, say I get a file which has a content from the above algorithm and I didn't know about this algorit...

PHP: 2 strings - which one is UTF-8 and which one not?

Hello! I have a database with lots of strings. Some of them are correctly UTF-8 encoded, some of them not. Therefore, I've set up a script which selects 100 strings from the db. The following function decides whether a string contains UTF-8 or not (no matter if it's correct): function detectUTF8($text) { return preg_match('%(?: ...

Encoding problems in PHP / MySQL

EDIT: After feedback from my original post, I've change the text to clarify my problem. I have the following query (pseudo code): $conn = mysql_connect('localhost', 'mysql_user', 'mysql_password'); mysql_query("SET NAMES 'utf8'; COLLATE='utf8_danish_ci';"); mysql_query("SELECT id FROM myTable WHERE name = 'Fióre`s måløye'", $conn); ...

How to GET data from an URL and save it into a file in binary in C#.NET without the encoding mess?

In C#.NET, I want to fetch data from an URL and save it to a file in binary. Using HttpWebRequest/Streamreader to read into a string and saving using StreamWriter works fine with ASCII, but non-ASCII characters get mangled because the Systems thinks it has to worry about Encodings, encode to Unicode or from or whatever. What is the ea...

How to strip the 8th bit in a KOI8-R encoded character?

How to strip the 8th bit in a KOI8-R encoded character so as to have translit for a Russian letter? In particular, how to make it in Python? ...

KOI8-R: Having trouble translating a string

This Python script gets translit for Russian letters: s = u'Код Обмена Информацией, 8 бит'.encode('koi8-r') print ''.join([chr(ord(c) & 0x7F) for c in s]) # kOD oBMENA iNFORMACIEJ, 8 BIT That works. But I want to modify it so as to get user input. Now I'm stuck at this: s = raw_input("Enter a string you want to translit: ") s = unic...