This project has moved and is read-only. For the latest updates, please go here.

Locale-specific code samples in Code Block Component

Nov 28, 2008 at 1:29 PM
I was trying to move the code samples away from code files, so I had made an external Examples.txt file in SHFB project folder with the folowing content:

#region IBlockElement.New
		int iblockId;
		BXIBlockElement element = new BXIBlockElement();

		element.Name = "Новый элемент";
		element.IBlockId = iblockId;

		element.Active = true;
		element.ActiveFromDate = DateTime.Now;
		element.ActiveToDate = DateTime.Now.AddMonths(1);

and then the folowing reference in XML comment:
<code source="Examples.txt" region="IBlockElement.New" />
Everything works fine except for the Russian text in the example. It's shown as square characters in CHM file.
I've tried to save Examples.txt то UTF-8 and change <xsl:output encoding> to windows-1251 (and even utf-8) in Colorizer/highlight.xsl, but with no success.
I did the same changes to Sandcastle XSL transformations - no success.

But the original Russian text in internal XML comments code examples is displayed fine, so, I think, there is a problem on how the Code Block Component reads the external file.

Is there a way to fix the problem?

Nov 28, 2008 at 5:32 PM
Edited Nov 28, 2008 at 5:35 PM
Currently, there isn't a way to specify the encoding of the source file.  As such, it defaults to UTF-8.  If you open the text file and resave it using UTF-8 encoding, that would work around the issue for the time being.  XML comments files are saved as UTF-8 so that's why they are correct in other comments within the topic.  I'll see about supporting an encoding attribute in a future release.

Work Item: