<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Encoding C# strings as Byte[] (Byte Arrays) and back again</title>
	<atom:link href="http://www.dijksterhuis.org/encoding-c-strings-as-byte-byte-arrays-and-back-again/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijksterhuis.org/encoding-c-strings-as-byte-byte-arrays-and-back-again/</link>
	<description>Information, news about programming in C#</description>
	<lastBuildDate>Sun, 21 Feb 2010 16:48:33 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Martijn</title>
		<link>http://www.dijksterhuis.org/encoding-c-strings-as-byte-byte-arrays-and-back-again/comment-page-1/#comment-318</link>
		<dc:creator>Martijn</dc:creator>
		<pubDate>Sun, 15 Feb 2009 04:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijksterhuis.org/?p=265#comment-318</guid>
		<description>This is a shot in the dark without seeing the original files of course. You will need to establish the source encoding first. If it isn&#039;t unicode then its probably a Japanese ISO-2022-JP or SHIFT-JIS encoded file. In Shift-JIS certain combinations of multiple high ASCII characters form a single Japanese character.  

Did you try something like: 

srInputFile = new StreamReader(filename,Encoding.GetEncoding(&quot;iso-2022-jp&quot;))

That should make sure the text is imported from ISO-2022 and correctly converted to Unicode on reading.</description>
		<content:encoded><![CDATA[<p>This is a shot in the dark without seeing the original files of course. You will need to establish the source encoding first. If it isn&#8217;t unicode then its probably a Japanese ISO-2022-JP or SHIFT-JIS encoded file. In Shift-JIS certain combinations of multiple high ASCII characters form a single Japanese character.  </p>
<p>Did you try something like: </p>
<p>srInputFile = new StreamReader(filename,Encoding.GetEncoding(&#8221;iso-2022-jp&#8221;))</p>
<p>That should make sure the text is imported from ISO-2022 and correctly converted to Unicode on reading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Laith</title>
		<link>http://www.dijksterhuis.org/encoding-c-strings-as-byte-byte-arrays-and-back-again/comment-page-1/#comment-308</link>
		<dc:creator>Laith</dc:creator>
		<pubDate>Fri, 13 Feb 2009 05:37:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijksterhuis.org/?p=265#comment-308</guid>
		<description>Hello

I am writing an app in C# which reads in a c/h (c-language) files, and removing certain lines of comments that meets a criteria.  These c/h files contain both English and Japanese comments. such as this line, if it will show up...
	u1_ret = (U1)SOME_CONST;  /* 仮に未確定とする */

The problem is that when writing the file back, the the Japanese comments are corrupted and show up as squares like this...
        u1_ret = (U1)SOME_CONST;  /* ���ɖ��m��Ƃ���*/

I am creating the streams as follows:
srInputFile = new StreamReader(filename);
swOutputFile = new StreamWriter(outputDir + &quot;\\_&quot; + outputFileName, false, srInputFile.CurrentEncoding);

Here is how i am writing to file
while (!srInputFile.EndOfStream)
{
    LineIn = srInputFile.ReadLine();
    if (IsTextMatch(LineIn) == false)
    {
        swOutputFile.WriteLine(LineIn.Normalize());
    }
}

I tried different encodings but the problem is still the same...
I appreciate your help...

regards
ld</description>
		<content:encoded><![CDATA[<p>Hello</p>
<p>I am writing an app in C# which reads in a c/h (c-language) files, and removing certain lines of comments that meets a criteria.  These c/h files contain both English and Japanese comments. such as this line, if it will show up&#8230;<br />
	u1_ret = (U1)SOME_CONST;  /* 仮に未確定とする */</p>
<p>The problem is that when writing the file back, the the Japanese comments are corrupted and show up as squares like this&#8230;<br />
        u1_ret = (U1)SOME_CONST;  /* ���ɖ��m��Ƃ���*/</p>
<p>I am creating the streams as follows:<br />
srInputFile = new StreamReader(filename);<br />
swOutputFile = new StreamWriter(outputDir + &#8220;\\_&#8221; + outputFileName, false, srInputFile.CurrentEncoding);</p>
<p>Here is how i am writing to file<br />
while (!srInputFile.EndOfStream)<br />
{<br />
    LineIn = srInputFile.ReadLine();<br />
    if (IsTextMatch(LineIn) == false)<br />
    {<br />
        swOutputFile.WriteLine(LineIn.Normalize());<br />
    }<br />
}</p>
<p>I tried different encodings but the problem is still the same&#8230;<br />
I appreciate your help&#8230;</p>
<p>regards<br />
ld</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://www.dijksterhuis.org/encoding-c-strings-as-byte-byte-arrays-and-back-again/comment-page-1/#comment-269</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Fri, 30 Jan 2009 16:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijksterhuis.org/?p=265#comment-269</guid>
		<description>I needed a quick reminder on encoding byte arrays, and ended up rethinking my approach because of the estra detail in your post.  appreciate it.</description>
		<content:encoded><![CDATA[<p>I needed a quick reminder on encoding byte arrays, and ended up rethinking my approach because of the estra detail in your post.  appreciate it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
