Skip to content

Instantly share code, notes, and snippets.

@s-trooper
Last active November 26, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-trooper/4112028358ef25f03c26 to your computer and use it in GitHub Desktop.
Save s-trooper/4112028358ef25f03c26 to your computer and use it in GitHub Desktop.
mono bug
-- Mono JIT compiler version 4.2.1 (Stable 4.2.1.102/6dd2d0d Thu Nov 12 09:52:44 UTC 2015)
This code worked in 4.0.4 and .NET as i don't get exception but yet.
btw my "OutputSettings.Encoding" is "System.Text.Latin1Encoding" as in xslt
```F#
open System.Xml
open System.Text
let xslt = new Xsl.XslCompiledTransform()
xslt.Load( "/export.xslt")
let ws = XmlWriter.Create("/output.xml", xslt.OutputSettings)
xslt.Transform("/input.xml", null, ws)
```
it run in an exception
```
System.ArgumentException: Conversion buffer overflow.
at System.Text.Encoder.Convert (System.Char[] chars, Int32 charIndex, Int32 charCount, System.Byte[] bytes, Int32 byteIndex, Int32 byteCount, Boolean flush, System.Int32& charsUsed, System.Int32& bytesUsed, System.Boolean& completed) <0x7f01564689c0 + 0x002ae> in <filename unknown>:0
at System.Xml.XmlEncodedRawTextWriter.FlushEncoder () <0x41b9af20 + 0x00084> in <filename unknown>:0
at System.Xml.XmlEncodedRawTextWriter.Flush () <0x41b9aa30 + 0x0001b> in <filename unknown>:0
at System.Xml.XmlWellFormedWriter.Flush () <0x41b9a9e0 + 0x0001f> in <filename unknown>:0
Stopped due to error
```
EDIT: the workaround is to set encoding to UTF8, seems mono xstl dont support Latin1? That work on all plaftorms and versions YET.
```
open System.Xml
open System.Text
let xslt = new Xsl.XslCompiledTransform()
xslt.Load( "/export.xslt")
let xws = xslt.OutputSettings.Clone()
xws.Encoding <- Encoding.UTF8
let ws = XmlWriter.Create("/output.xml", xws)
xslt.Transform("/input.xml", null, ws)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment