encoding

ProtectedData.Protect intermittent failure

I'm writing a password encryption routine. I've written the below app to illustrate my problem. About 20% of the time, this code works as expected. The rest of the time, the decryption throws a cryptographic exception - "The data is invalid". I believe the problem is in the encryption portion, because the decryption portion works the...

Why is there a difference between the encoding of the Windows Command Prompt vs. a batch file?

For example, suppose I have a batch file called 'test.cmd' and it simply contains: echo %1 I can call this directly from the command prompt with 'test.cmd some¬arg' and the result is that the string 'some¬arg' is printed. However if I place that same call in a second batch file, called 'tester.cmd' for the sake of argument, and I cal...

How do I safely create an XPathNavigator against a Stream in C#?

Given a Stream as input, how do I safely create an XPathNavigator against an XML data source? The XML data source: May possibly contain invalid hexadecimal characters that need to be removed. May contain characters that do not match the declared encoding of the document. As an example, some XML data sources in the cloud will have a ...

Codepages and encodings

Hi, Before anyone recommends that I do a google search on this, I have. I just need a bit more clarity around what codepages and encodings. If I use UTF8 encoding, and use an italian code page and then a french code page, does this mean ill get different characters even though the bytes havent changed? ...

How does one handle file type changes in Perforce?

When you add a file to Perforce, it attempts to determine what type of file it is (text, binary, utf16, etc.). It's does a good job of this, but apparently never checks the file type again after the initial submission to version control. A coworker recently made a change to a text file that converted it to Unicode (utf16). Perforce di...

SAX parser breaking on ñ

I have implemented a SAX parser in Java by extending the default handler. The XML has a ñ in its content. When it hits this character it breaks. I print out the char array in the character method and it simply ends with the character before the ñ. The parser seems to stop after this as no other methods are called even though there is sti...

Handling UTF-8 encoding

We have an Java application running on Weblogic server that picks up XML messages from a JMS or MQ queue and writes it into another JMS queue. The application doesn't modify the XML content in any way. We use BEA's XMLObject to read and write the messages into queues. The XML messages contain the encoding type declarations as UTF-8. We...

.NET: Convert .doc to .htm results in funky characters

I've used MS Word automation to save a .doc to a .htm. If there are bullet characters in the .doc file, they are saved fine to the .htm, but when I try to read the .htm file into a string (so I can subsequently send to a database for ultimate storage as a string, not a blob), the bullets are converted to question marks or other characte...

Converting WAV files to MP3 using VB6?

I need help converting WAV files to MP3 format in VB6. I did already find source code in C#, but I can't use that ...

php output showing little black diamonds with a question mark

I'm writing a php program that pulls from a db source. Some of the varchars have quotes that are displaying as black diamonds with a question mark in them (unkown charecters, I assume from microsoft word text). How can I use php to strip these charecters out? ...

Unicode Character Not Showing

I want to display the "infinity" symbol using CGContextSelectFont(context, "HelveticaNeue", textSize, kCGEncodingMacRoman); CGContextShowTextAtPoint(context, myCenter.x, myCenter.y + textHeight, [sName cStringUsingEncoding:NSMacOSRomanStringEncoding], [sName length]); It is displayed as a square box, or a circle. I have found...

pulling location.href or window.location from fire fox without it being encoded

Hi! I'm passing a url through google translate and in my location bar on Fire fox, the url looks as it should: http://72.14.235.104/translate_c?hl=en&langpair=en|ru&sl=ru&tl=ru&u=http://something.something/something/.....orig_term%3Dмалярии I want to grab the orig_term and apply its value other places on my page as it ...

In C#, how do I save a webpage to file without destroying whatever the encoding is?

Here's what I got so far (that doesn't work). At this point I thought my target was Ansi encoded, but I really don't want to have to know at this point. My browser seems to be able to determine what encoding to use, How can I? static void GetUrl(Uri uri, string localFileName) { HttpWebRequest request = (HttpWebRequest)WebRequest.Cre...

WPF: TIFF images with JPEG compression?

I have a large number of TIFF images that I’d need to use in a WPF program (.NET 3.5 SP1 specifically and using C#). Half of the TIFF files contain color images encoded using JPEG compression and they don’t work with WPF. The “Microsoft Office Document Imaging” application handles the files fine. As Windows itself doesn’t really like the...

MySQL won't maintain character information while importing

I'm trying to import a large SQL file; created by mysqldump on one server, then converted with iconv; using these commands: $ mysqldump -uxxx -p xxx > data.sql $ iconv -f UTF-8 -t ISO-8859-1//TRANSLIT data.sql data.iconv.sql I noticed that the "\x91" in the database had turned into "\xc3\x82\xc2\x91" in the dump, because mysqldump tri...

Is there a better way to convert to ASCII from an arbitrary input?

I need to be able to take an arbitrary text input that may have a byte order marker (BOM) on it to mark its encoding, and output it as ASCII. We have some old tools that don't understand BOM's and I need to send them ASCII-only data. Now, I just got done writing this code and I just can't quite believe the inefficiency here. Four copies...

Decode gzipped web page retrieved via cURL in PHP

I'm retrieving a gzipped web page via curl, but when I output the retrieved content to the browser I just get the raw gzipped data. How can I decode the data in PHP? One method I found was to write the content to a tmp file and then ... $f = gzopen($filename,"r"); $content = gzread($filename,250000); gzclose($f); .... but man, there'...

MP3 Encoding in Java

I need an OpenSource API in Java, which can encode *.wav and *.au formats to MP3, and vice-versa. Have evaluated Java Sound API, and LameOnJ, but they dont meet the requirements and aint stable, respectively. Please suggest one that is free, and platform independent. ...

Chunked Encoding Implementation in .NET (or at least pseudo code)

I wrote a raw TCP client for HTTP/HTTPS requests, however I'm having problems with chunked encoding responses. HTTP/1.1 is requirement therefore I should support it. Raw TCP is a business requirement that I need to keep, therefore I can't switch to .NET HTTPWebRequest/HTTPWebResponse However if there is way to convert a RAW HTTP Request...

Get encoding of page/iframe via JavaScript

I'd like to programatically determine the encoding of a page via JavaScript, or some other API from a browser. The reason I want this information is because I am attempting to fuzz major browsers on what character encodings they support, and obviously just because I sent the appropriate "Content-Type" doesn't mean that the browser will d...