encoding

Is it possible to peek at the data in a urllib2 response?

I need to detect character encoding in HTTP responses. To do this I look at the headers, then if it's not set in the content-type header I have to peek at the response and look for a "<meta http-equiv='content-type'>" header. I'd like to be able to write a function that looks and works something like this: response = urllib2.urlopen("...

Is the implementation of response.info().getencoding() broken in urllib2?

I would expect the output of getencoding in the following python session to be "ISO-8859-1": >>> import urllib2 >>> response = urllib2.urlopen("http://www.google.com/") >>> response.info().plist ['charset=ISO-8859-1'] >>> response.info().getencoding() '7bit' This is with python version 2.6 ('2.6 (r26:66714, Aug 17 2009, 16:01:07) \n[G...

Java - Image encoding in XML

Hi everyone, I thought I would find a solution to this problem relatively easily, but here I am calling upon the help from ye gods to pull me out of this conundrum. So, I've got an image and I want to store it in an XML document using Java. I have previously achieved this in VisualBasic by saving the image to a stream, converting the s...

Writing a Text file from VB.NET (Encoding Problem)

I am writing an application that must generate a plain Text file with fixed sized columns. my current code is: Dim MyFilePath As String = Path & FILE_PREFIX & FileNr & ".TXT" IO.File.Delete(MyFilePath) Dim FileStr As New IO.StreamWriter(MyFilePath, False, <ENCODER HERE>) Do While r.Read FileStr.WriteLine(r("TXTLine")) Loop FileSt...

Bad Request when posting xml to REST-like service - specal characters

Hi I am integrating an app with a service (iContact), that describes its API as "rest-like". I post XML, and everything works fine... Until I send special characters like æøå - then I get a "bad request" error from the server. <contacts> <contact> <firstname>Søren</firstname> <lastname>ÆbleTårn</lastname> </contact> </conta...

How in ASP.NET MVC to change Url.Encode character replacement strategy?

I'm using Url.Encode within a view and it's replacing spaces with + so instead of: /production/cats-the-musical I'm getting .../cats+the+musical. I'm sure this is an easy one, but where do you go to configuring which characters are used for this? I'll be doing this: public static string EncodeForSEO(this UrlHelper helper, string unen...

Strip Byte Order Mark from string in C#

Hi, I've read similar posts on this and they don't answer my question. In C#, I have a string that I'm obtaining from WebClient.DownloadString. I've tried setting client.Encoding to new UTF8Encoding(false), but that's made no difference - I still end up with a byte order mark for UTF-8 at the beginning of the result string. I need to re...

How to generate javadoc documentation with umlauts?

I am trying to generate javadocs in eclipse. The source files are UTF-8 encoded and contain some umlauts. The resulting html files do not specify an encoding and do not use html entities, so the umlauts aren't displayed correctly in any browser. What can I do to change this? ...

War file deployment

I wrote a jsp application, and if I generate a war file with eclipse in windows XP, language: tradition Chinese. and deploy to weblogic, it will have such problem: inputAdministrator.jsp:251:11: This type name is ambiguous because it matches more than one '*'-import, including 'java.io.*' and 'admin.iguard.businessObject.*'. ...

Mechanize Iconv::IllegalSequence when trying to form POST query

Hello, the following code raises the aforementioned error, how can I fix that? require 'mechanize' m = WWW::Mechanize.new p = m.get('http://art-mobile.com.ua/register.php') f = p.forms.first f.submit(f.buttons.last) Just in case, here is the full description of an error on my box D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/w...

Encoding in UTF-8 from PHP

I am not that good with encoding but I am even falling over with the basics here. I am trying to create a file that is recognised as UTF-8 header("Content-Type: text/plain; charset=utf-8"); header("Content-disposition: attachment; filename=test.txt"); echo "test"; exit(); also tried header("Content-Type: text/plain; charset=utf-8");...

How do I import using FasterCSV a row with a name like "Ciarán"?

I am trying to load in my data migration a member database. Quite a few of the names have special characters such as "Ciarán". I've set up a simple example like this: require 'rubygems' require 'fastercsv' FasterCSV.foreach("/Users/developer/Work/madmin/db/data/Members.csv") do |row| puts row.inspect end and I get the following: ...

Decode encoded html to display in SIlverlight

I have text I am displaying in SIlverlight that is coming from a CMS that is used to store web content. There are fields in the cms like name and description that contain html tags and encoded characters. What is the best way to convert/strip these from the text so they can be displayed in a silverlight textblock I am leaning towards r...

Saving characters such as ä, ü, ö and ß to a text file doesn't work in Germany

Hi all, I have a program that displays the characters correctly ä, ü, ö, ß in a datagrid and saves them correctly to a text file but I someone in Germany using a German copy of Windows is unable to save to a text file correctly and simply sees a question mark in place of the characters? I've tried using ASCII, Unicode and UTF8, all wor...

How do sites like tinyurl generate urls?

I looked at tinyurl, tinypic, imgur and youtube! I thought they would use a text safe representation of a index and use it as a primary ID in their DB. However trying to put the keys into Convert.FromBase64String("key") yields no results and throw an exception. So these sites dont use a base64 array. What are they using? What might i wan...

How can I speed up a video by dropping frames?

I've got a video that's 30 minutes long. I want to make a speeded up version that's (say) 15 minutes long. I could do this by dropping every 2nd frame. How can I do this on linux? I'm playing with gstreamer and it looks cool. Is there a way to do this with gstreamer? What would be the gst-launch command line to do it? My source video i...

Overriding grails.views.default.codec='html' config back to 'none'

If I leave grails.views.default.code='none' in the grails Config.groovy, it's up to me to HTML encode my expressions explicitly in the GSP files: ${myValue?.encodeAsHTML()}. If I set grails.views.default.codec='html" in the Config.groovy, then the HTML encoding happens automatically for every expression: ${myValue}. My question: If I s...

ASP.NET 3.5 / IIS 6 Output Garbled / Corrupt

I have inherited a web application and when trying when trying to put it on the same server on a different IP and IIS site I get a page full of stuff like this in all browsers. (not sure how the server here will output this but it is basically the same as if you were to open a binary in a text editor or bad character encoding). ���r#ə6�...

Reliable email encoding.

What are the most reliable encodings for sending email? I had some problems recently with .NET's System.Net.Mail default of quoted-printable ('=0D=0A' scattered throughout the message). So I changed to iso-8859-1 for the body (set via alternative views), and 7bit for transfer (and base64 for embedded resources). Are there the better ch...

What is the difference between utf8_general_ci and utf8_unicode_ci in MySql?

Are there any big differences a developer should care about? ...