Search code examples
firefoxpluginsinternationalizationnpapinpruntime

Problem passing non-ASCII string to NPN_Invoke


My plugin calls JavaScript function using NPN_Invoke, passing a string argument to it. Everything works fine if all characters in it are ASCII. But if there're non-ASCII characters in the string, then JavaScript receives an empty string.

I verified that an NPVariant variable (or, rather, an array item), passed to NPN_Invoke, still contain a valid string, so it appears as if something wrong happens on the browser side.

Is this really a Firefox bug (I tested on Windows with FF 3.6 and 4.0), or I am doing something wrong? Any workarounds?


Solution

  • This isn't a bug; NPAPI only accepts UTF8 strings. If the string is not valid UTF8, then the browser won't accept it. You can't use NPString to pass binary data.