encoding

URL shortener: best encoding method?

I'm creating a link shortening service and I'm using base64 encoding/decoding of an incremented ID field to create my urls. A url with the ID "6" would be: http://mysite.com/Ng== I need to also allow users to create a custom url name, like http://mysite.com/music Here's my (possibly faulty) approach so far. Help in fixing it would be a...

How to encode a value in PKCS7 with Java?

Hi, I would like to use PKCS7 encryption to encode a value together with Java and Java Servlet. Is there any available library and references to do the encryption? Any sample or tutorial that I could follow? Thank you. ...

Java - XSS - HTML encoding - Character entity reference vs. Numeric entity reference

We've been looking for ways to HTML encode our JSP pages to counter XSS. The OWASP site shows How_to_perform_HTML_entity_encoding_in_Java The article talks about entity encoding the "Big 5" i.e. 21 {"#39", new Integer(39)}, // ' - apostrophe 22 {"quot", new Integer(34)}, // " - double-quote 23 {"amp", ...

Opening HTML source code in Cocoa

I'm trying to display HTML source code in my NSDocument based application. However, it renders the page as Safari would show it. Here's the code that I use to open HTML: NSData*data; NSMutableDictionary *dict = [NSDictionary dictionaryWithObject:NSHTMLTextDocumentType ...

Character encoding problem

Hi, I was recently editing a Unicode-encoded text file that also includes Thai characters (alongside "normal" characters). For some reason, after each sequence of Thai characters, a new line appeared. After some mucking around with C, trying to remove all newline characters, I fired up vim to inspect the file. Apparently, after each Th...

Encoding / Error Correction Challenge

Is it mathematically feasible to encode and initial 4 byte message into 8 bytes and if one of the 8 bytes is completely dropped and another is wrong to reconstruct the initial 4 byte message? There would be no way to retransmit nor would the location of the dropped byte be known. If one uses Reed Solomon error correction with 4 "parity...

solve copy/paste encoding problems?

I hear that you can copy paste text from MS word and send an email or post something and there will be an encoding problem. I also heard from someone else its only a problem with webpages that cant handle unicode. Is it possible to have a doc that cannot be copy/paste to a webbrowsers/apps properly? (assuming its all text and only has a...

How to replace special characters with their equivalent (such as " á " for " a") in C#?

Hi. I need to get the Portuguese text content out of an Excel file and create an xml which is going to be used by an application that doesn't support characters such as "ç", "á", "é", and others. And I can't just remove the characters, but replace them with their equivalent ("c", "a", "e", for example). I assume there's a better way to...

.Net using Chr() to parse text

I'm building a simple client-server chat system. The clients send data to the server and the server resends the data to all the other clients. I'm using the TcpListener and Network stream classes to send the data between the client and the server. The fields I need to send are, for example: name, text, timestamp, etc. I separate them u...

$_GET encoding problem with cyrillic text

I'm trying this code (on my local web server) <?php echo 'the word is / думата е '.$_GET['word']; ?> but I get corrupted result when enter ?word=проба the word is / думата е ���� The document is saved as 'UTF-8 without BOM' and headers are also UTF-8. I have tried urlencode() and urldecode() but the effect was same. When upload it ...

Technique for ensuring HTML- and URL-encoding

Has anyone implemented a good system for ensuring that output is properly HTML-encoded where it makes sense? Maybe even something that recognizes when output should be URL-encoded or JSON-encoded instead? The lazy approach — just encoding all inputs — causes problems when you want to send those inputs to a database, or to a block of Jav...

D (Tango) can read and write ANSI files ?

With D and Tango library can I read and write in the ANSI encoding ? ...

Open mails in outlook from java using the protocol "mapi://"

I developp a Java application using Windows Desktop Search from which I can retrieve some information about files on my computer such as urls (System.ItemUrl). An example of such url is file://c:/users/ausername/documents/aninterestingfile.txt for "normal" files. This field give also urls of mail items indexed from Outlook or Thunderb...

Conversion from string to wstring is causing ú to lose encoding

The variable filepath which is a string contains the value Música. I have the following code: wstring fp(filepath.length(), L' '); copy(filepath.begin(), filepath.end(), fp.begin()); fp then contains the value M?sica. How do I convert filepath to fp without losing the encoding for the ú character? ...

VB.Net MailMessage text encoding issue

I have an ASP.Net app that allows a user to write text into a Telerik RadEditor control and then send an email. For some reason I'm sometimes getting strange characters showing up in the email that is generated. For example if I put the word Test’s into the RadEditor box and send it... the email shows up with the text changed to: Testâ...

Best way to correct garbled data caused by false encoding

Hi all, I have a set of data that contains garbled text fields because of encoding errors during many import/exports from one database to another. Most of the errors were caused by converting UTF-8 to ISO-8859-1. Strangely enough, the errors are not consistent: the word 'München' appears as 'München' in some place and also as 'MÃœnchen...

Properly handling unicode characters in Rails

By default Rails allows users of our application to input non-utf8 data, such as: ¶®«¼ However when we attempt to retrieve the data from our database and render it in a template Rails incorrectly assumes that it is in UTF-8 format and throws an error. ArgumentError: invalid byte sequence in UTF-8 What is the best way to handle this? ...

Java: How to detect (and change?) encoding of System.console ?

I have a program which runs on a console and its Umlauts and other special characters are being output as ?'s on Macs. Here's a simple test program: public static void main( String[] args ) { System.out.println("höhößüä"); System.console().printf( "höhößüä" ); } On a default Mac console (with default UTF-8 encoding), this prin...

SDK to encode media with FairPlay DRM?

My company runs a video website. We currently make our content available via streaming, and download to Windows PCs with WMRM DRM. We're looking to make content available to download for Macs but would need to protect them with the FairPlay DRM system. Is this something that we can do, or is FairPlay proprietary and only permitted to be...

save png image with custom quality or color depth in C#

I wanted to know how could I change the quality or color depth of an image and save it in PNG. The encoder method seems to work only for jpegs. Thanks in advance. ...