views:

436

answers:

2
+4  A: 

Your string is not ASCII, so you are either using a string to represent binary data, or you're not maintaining awareness of multi-byte encoding. In any case, the simplest way to deal with any Internet-based technology (HTTP, SMTP, POP, IMAP) is to encode it as 7-bit clean. One common way is to base64-encode your data, send it across the wire, then base64-decode it before trying to process it.

Tom
Not sure why so many +1 votes here - this answer seems irrelevant to the question, which obviously deals with web programming ("Htmlencode" in addition to the asp.net tag). You cant base64 encode strings to display to users in a web page. (No offense, Tom.) But maybe I'm wrong...
wuputah
@wupatah - Yes, you're wrong. The OP's question is explicitly about posting binary data, not about displaying data to users. This answer is relevant to how HTTP works.
Tom
+1  A: 

I believe this is what you're looking for:

!"#$%&'()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]\\^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅàáâäèçéêëìíîïôö÷òóõùúý

You just need to use a better html entity/encoding library or tool. The one I used to generate this is from Ruby - I used the HTML Entities library. The code I wrote to do this follows. I had to put your text in input.txt to preserve Unicode (there was an EOF character in the string), but it worked great.

require 'rubygems'
require 'htmlentities'

str = File.read('input.txt')

coder = HTMLEntities.new
puts coder.encode(str, :named)
wuputah