Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Plugin and Companion App SDK
Viewing all articles
Browse latest Browse all 54282

Displaying UTF-8 strings in a Photoshop Panel

$
0
0

Hi all,

 

I'm passing a UTF-8 string from my plugin to my Photoshop panel and using that string to set the label on a control.  This looks fine until it tries to display a non-ASCII character such as an ellipsis.

 

The string started out life as a CFStringRef inside my plugin, and was converted to UTF-8 with:

 

CFStringGetCString(inSourceCFString, buffer, buffersize, kCFStringEncodingUTF8);

 

I've tried various ways of manipulating the string including using a ByteArray and the write/readMultiByte calls with various charSet arguments, all to no avail.  I also tried using the example here to add a BOM to the string, which also didn't work.

 


// Instead of About…, the ellipse (…) displays as gibberish. The hex UTF-8 code for 
// an ellipse is E2 80 A6.

private function initAboutButton():void{
     aboutButton.label = getLocalizedString(kAboutButtonString);
}

public function getLocalizedString(stringID:Number):String{
     var reqResult:SyncRequestResult =           CSXSInterface.instance.evalScript("getLocalizedString", stringID.toString()); // JavaScript queries the plug-in     var result:String = new String();          if (SyncRequestResult.COMPLETE == reqResult.status)     {          try          {               var bytes:ByteArray = new ByteArray();                              bytes.writeMultiByte(reqResult.data.localizedString, "utf-8");               bytes.position = 0;               result = bytes.readMultiByte(bytes.length, "unicode"); // Tried utf-8, us-ascii, unicode/unicodeFFFE (BE)          }          catch(err:Error)          {               result = err.message;          }     }          return result;
}

 

 

Any ideas?

 

Thanks,

Mike


Viewing all articles
Browse latest Browse all 54282

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>