snussbaumer 0 Newbie Poster

Hi all,
I've been through all the documentation here, I've been searching this problem for a while now but could not find any solution.

I created a custom CharsetProvider the following way :

  • created a class extending Charset doing my custom encoding
  • created a class extending CharsetProvider returning the previous class
  • added my provider to META-INF/services/java.nio.charset.spi.CharsetProvider
  • created a test class doing only the following : java.nio.charset.Charset.isSupported("MyCustomCharsetFromAbove")
  • created a simple applet calling the test class above

I then created a jar file, signed it and tried the Test class from

  1. The command line (java -jar myJar.jar, having a Main entry in the manifest)
  2. From a browser through the applet

In the first case my custom charset is supported, in the second case (from the browser) it is not supported. I'm using the same jar file in both cases, I can access files through the applet from the browser (so I have file read and write permission)

I don't get why my CharsetProvider doesn't get loaded ? Do I miss something here ?

Tip : if I put a bad CharsetProvider name in META-INF/services/java.nio.charset.spi.CharsetProvider I get an exception when I test from the command line, but do not get that exception in the browser environment. It's as if the java plugin doesn't even try to read that file ...

Why I'm trying to do this ? I desperately need Cp850 encoding support in my Applet, and the problem is Cp850 isn't provided by all JVMs. So I figured I'd add Cp850 code to my sources and so provide it all the time with my applet. There is maybe a simpler way to do this than creating a custom CharsetProvider, but I couldn't find one...

Thanks,
Sebastien

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.