encoding

problem using base64 encoder and InputStreamReader

I have some CLOB columns in a database that I need to put Base64 encoded binary files in. These files can be large, so I need to stream them, I can't read the whole thing in at once. I'm using org.apache.commons.codec.binary.Base64InputStream to do the encoding, and I'm running into a problem. My code is essentially this FileInputStre...

Encode/decode a long to a string using a fixed set of letters in Java

Given an arbitrary set of letters String range = "0123456789abcdefghijklmnopABCD#"; I am looking for 2 methods to encode/decode from long <-> String String s = encode( range, l ); and long l = decode( range, s ); So decode(range, encode(range, 123456789L)) == 123456789L And if range is "0123456789" thats the usual way of encodi...

String codification to Twitter

I'm developing a program that sends tweets. I have this piece of code: StringBuilder sb = new StringBuilder("Recomendo "); sb.append(lblName.getText()); sb.append(" no canal "+lblCanal.getText()); sb.append(" no dia "+date[2]+"/"+date[1]+"/"+date[0]); sb.append(" às "+time[0]+"h"+time[1]); byte[] defaultStrBytes = ...

Echo cancellation

Can any of you suggest a good and stable echo cancelation package (gnu or not) to be linked with my videoconference application (C/C++) (Windows / Linux / MacOSX) ? My application should be freeware, so i do not want to pay for each user who download the app. ...

StAX - Setting the version and encoding using XMLStreamWriter

Hi, I am using StAX for creating XML files and then validating the file with and XSD. I am getting an error while creating the XML file: javax.xml.stream.XMLStreamException: Underlying stream encoding 'Cp1252' and input paramter for writeStartDocument() method 'UTF-8' do not match. at com.sun.xml.internal.stream.writers.XMLStre...

How do I transform "é" to &#233; in php?

I have an XML ISO-8859-1 page, in which I have to output symbols like é. If I output &eacute; it errors out. &#233; works just fine. So, what PHP function should I use to transform é to &#233; I can't move to utf-8 (as I assume some will suggest and rightfully so) This is a huge, legacy code. ...

Problem with greek characters using java

I am trying to write greek characters to a file using java like this: String greek = "\u03c1\u03ae\u03bc. \u03c7\u03b1\u03b9\u03c1\u03b5\u03c4\u03ce"; try { BufferedWriter out = new BufferedWriter(new FileWriter("E:\\properties\\outfilename.txt")); out.write(greek); out.close(); } catch (IOException e) ...

Python: Mat-File into hex-values

filename = r"C:\Dokumente und Einstellungen\sschnei1\Desktop\a.mat" print open(filename, "r").read().encode("hex") The code above only work for text files. But I want to read out the hex-values of mat-files. EDIT: my little hex-editor from textwrap import fill filename = r"C:\a.mat" hexvalues = open(filename, "rb").read().encode("hex...

How to post non-latin1 data to non-UTF8 site using perl?

I want to post russian text on a CP1251 site using LWP::UserAgent and get following results: # $text="Русский текст"; obtained from command line FIELD_NAME => $text # result: Г?в г'В?г'В?г'В?г?вєг?вёг?в? Г'В'Г?вчг?вєг'В?г'В' $text=Encode::decode_utf8($text); FIELD_NAME => $text ...

Unable to encode to iso-8859-1 encoding for some chars using Perl Encode module

I have a HTML string in ISO-8859-1 encoding. I need to pass this string to HTML:Entities::decode_entities() for converting some of the HTML ASCII codes to respective chars. To so i am using a module HTML::Parser::Entities 3.65 but after decode_entities() operation my whole string changes to utf-8 string. This behavior seems fine as the d...

weird characters in HTML email

Hi stackers! I'm reading email from a maildir and some emails have weird sets of characters in them: =3D =09 I think =3D is = and =09 is a space. There are some others, but I'm not sure: =E2 =80 =93 Does anyone know what these are and what encoding issues I'm dealing with here? BTW, I tried fetching these email via POP3 and it's ...

Perl strings internals

How do perl strings represented internally? What encoding is used? How do I handle different encodings properly? I've been using perl for quite a long time, but it didn't include a lot of string handling in different encodings, and when I encountered a minor problem that had something to do with encodings I usually resorted to some sham...

Issue encoding java->xls

This is not a pure java question and can also be related to HTML I've written a java servlet that queries a database table and shows the result as a html table. The user can also ask to receive the result as an Excel sheet. Im creating the Excel sheet by printing the same html table, but with the content-type of "application/vnd.ms-exce...

Python "string_escape" vs "unicode_escape"

According to the docs, the builtin string encoding string_escape: Produce[s] a string that is suitable as string literal in Python source code ...while the unicode_escape: Produce[s] a string that is suitable as Unicode literal in Python source code So, they should have roughly the same behaviour. BUT, they appear to treat si...

What c# equivalent encoding does Python's hash.digest() use ?

I am trying to port a python program to c#. Here is the line that's supposed to be a walkthrough but is currently tormenting me: hash = hashlib.md5(inputstring).digest() After generating a similar MD5 hash in c# It is absolutely vital that I create a similar hash string as the original python program or my whole application will fail....

problem with '/' in the REST URL parameters for an Ajax call

var url = relativeURI+'/rest/PPS/Prod/'+encodeURIComponent(prod)+'/Section/'+encodeURIComponent(section); $j.ajax({ url: url, type: 'POST', error: function(){ alert('Error'); }, success: function(){ alert('ItWorks'); } }); } In this ajax call, if I have '/' in the parameters prod or sec, then there is an erro...

Jquery ajax call and charset windows-1252

Dear stackoveflow, I have this problem. I'm working with an old version of mssql (2000) that has all the tables encoded in windows 1252 (and that's it). I can write and read succesfully with php using this line: <?php header('Content-Type: text/html; charset=windows-1252'); ?> If I make a normal post everything works as expected, If I...

Setting encoding in Grails controller's render method

Hello, I'm trying to build an RSS feed using Grails and Rome. In my controller's rss action, my last command is : render(text: getFeed("rss_2.0"), contentType:"application/rss+xml", encoding:"ISO-8859-1 ") However, when I navigate to my feed's URL, the header is : <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:dc="http://pu...

Latin characters in phpMyAdmin with UTF-8 collation

My website uses: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; And this meta: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> I created my database and tables in phpMyAdmin making sur...

How to encode 'á' to '&#225' with C# ?? (UTF8)

Hi all I'm trying to write an XML file with UTF-8 encode, and the original string can have invalid characters like 'á', so, i need to change these invalid characters to a valid ones. I know that there is an encoding method that take, for example, character á and transform it to group of characters &#225;. I am trying to achive this wi...