I have been able to re-create this issue (and can suggest a fix).
Microsoft inserts control chars when you use the inbuilt globalisation. For example if you use the following winrt code:-
Windows.Globalization.DateTimeFormatting.DateTimeFormatter datef =
new DateTimeFormatter("longdate");
string text= datef.Format(TheDate);
And then output text you will see something that looks like this:
text = "01 May 2013"
However if you do a .length on it you will get 16 chars (not 11 as you would expect). Looking at the char array you see the following:-
text.ToCharArray()
{char[16]}
[0]: 8206 ''
[1]: 48 '0'
[2]: 49 '1'
[3]: 8206 ''
[4]: 32 ' '
[5]: 8206 ''
[6]: 77 'M'
[7]: 97 'a'
[8]: 121 'y'
[9]: 8206 ''
[10]: 32 ' '
[11]: 8206 ''
[12]: 50 '2'
[13]: 48 '0'
[14]: 49 '1'
[15]: 51 '3'
The Syncfusion print code uses a 256 char to byte conversion table, but because 8206 is above that we get an index out of range exception.
You can fix it by changing the GetBytes method in the System.Text.Windows1252Encoding.cs file to this:
public override byte[] GetBytes(string s)
{
List<byte> list = new List<byte>();
foreach (char ch in s)
{
int index = (int) ch;
if (index<Windows1252Encoding.m_charCodeTable.Length)
{
list.Add((byte) Windows1252Encoding.m_charCodeTable[(int) ch]);
}
}
return list.ToArray();
}
If you are an end user and you want to work around the bug then you can use the following linq to cleanse your string before passing it to the
text = new string(text.ToCharArray().Where(p => (int) p < 256).ToArray());
This code changes you string to:-
text.ToCharArray()
{char[11]}
[0]: 48 '0'
[1]: 49 '1'
[2]: 32 ' '
[3]: 77 'M'
[4]: 97 'a'
[5]: 121 'y'
[6]: 32 ' '
[7]: 50 '2'
[8]: 48 '0'
[9]: 49 '1'
[10]: 51 '3'
Hopefully that should be enough info to help fix the issue
Thanks
Ross