file.encoding gb2312

View: New views
1 Messages — Rating Filter:   Alert me  

file.encoding gb2312

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Thanks Jeroen, we have a happy customer.
 
Michael Kay


From: Samu Zhang (CS&S) [mailto:v-samzha@...]
Sent: 28 March 2008 11:24
To: Michael Kay
Subject: RE: Is this one bug ?

Hi Michael Kay,

 

Thank you for your great support.

 

I set encoding info in app.config file and it works fine on my pc now.

 

  <appSettings>
    <add key="ikvm:file.encoding" value="utf8" />
  </appSettings>

 

It looks like the encoding info which written in app.config will be loaded at an early time. And this is more stablle than load it in StringHelper.getCharset method.

 

By the way, I will paste these emails in my msn space for someone else can search it.

 

 

Regards

Samu Zhang

 

From: Michael Kay [mailto:mike@...]
Sent: Friday, March 28, 2008 7:04 PM
To: Samu Zhang (CS&S)
Subject: RE: Is this one bug ?

 

I received this response from Jeroen Frijters, who develops IKVM:

 

The file.encoding system property determines the default encoding and it is set based on the .NET default encoding, so that's why it can be a non-existing encoding (unfortunately it's not really possible to validate if an encoding is available that early in the library initialization process).

As a workaround you can explicitly set file.encoding in the app.config. See http://osdir.com/ml/java.ikvm.devel/2005-03/msg00049.html for more info.

 

I haven't actually had to use the app.config file before. It seems you can set Java system properties for use by the IKVM runtime, with the format

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="ikvm:file.encoding" value="utf8" />
  </appSettings>
</configuration>

It looks as if file.encoding is used during IKVM initialization, so setting it from your application code using System.setProperty() isn't likely to work.

Regards,

Michael Kay, Saxonica

 


From: Samu Zhang (CS&S) [mailto:v-samzha@...]
Sent: 28 March 2008 08:16
To: mike@...
Cc: Samu Zhang (CS&S)
Subject: Is this one bug ?

Hi mike,

 

I am a Chinese programmer working with  dotnet . I use saxon_9.0_ B to transform xml file by writing one stylesheet in xslt 2.0 . But I get one error.

 

Please help.

 

Stack trace:

 

[UnsupportedEncodingException: Encoding: gb2312 not found.]

   java.lang.StringHelper.getCharset(String ) +469

   java.lang.StringHelper.getBytes(String , String ) +86

   java.lang.StringHelper.getBytes(String ) +71

 

[Error: java.io.UnsupportedEncodingException: Encoding: gb2312 not found.]

   java.security.AccessController.doPrivileged(PrivilegedAction action) +150

   java.util.logging.Logger..cctor() +81

 

[TypeInitializationException: The type initializer for 'java.util.logging.Logger' threw an exception.]

   java.util.logging.Logger.getLogger(String name) +0

   gnu.classpath.ServiceFactory..cctor() +26

 

[TypeInitializationException: The type initializer for 'gnu.classpath.ServiceFactory' threw an exception.]

   gnu.classpath.ServiceFactory.lookupProviders(Class spi) +0

   java.nio.charset.Charset.providers2() +261

   java.nio.charset.Charset.charsetForName(String ) +68

   java.nio.charset.Charset.forName(String charsetName) +81

   java.io.OutputStreamWriter..ctor(OutputStream out) +237

   net.sf.saxon.Controller.transformDocument(NodeInfo startNode, Result result) +487

   Saxon.Api.XsltTransformer.Run(XmlDestination destination) +162

   WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\lenovo\×ÀÃæ\aaa\WebApplication1\WebApplication1\WebForm1.aspx.cs:50

   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15

   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33

   System.Web.UI.Control.OnLoad(EventArgs e) +99

   System.Web.UI.Control.LoadRecursive() +47

   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

 

This is my code:

 

 

            TextWriter stringWriter = new StringWriter();

                

            // Create a Processor instance.

            Processor processor = new Processor();

 

            // Load the source document

            XdmNode input = processor.NewDocumentBuilder().Build(new Uri(Server.MapPath("XMLFile1.xml")));

 

            // Create a transformer for the stylesheet.

            XsltTransformer transformer = processor.NewXsltCompiler().Compile(new Uri(Server.MapPath("XSLTFile1.xslt"))).Load();

 

            // Set the root node of the source document to be the initial context node

            transformer.InitialContextNode = input;

 

            // Create a serializer

            Serializer serializer = new Serializer();

            serializer.SetOutputWriter(stringWriter);

 

            // Transform the source XML to System.out.

            transformer.Run(serializer);

           

 

            stringWriter.Close();

 

 

Regards

Samu Zhang

 


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers
LightInTheBox - Buy quality products at wholesale price