[Flashcoders] SOLUTION: converting string to unicode range

2010-04-15 Thread allandt bik-elliott (thefieldcomic.com)
hey guys

spent a couple of hours googleoogling around to find something to quickly
convert a string of special characters into a unicode range to no avail so
i've written a function to do it for me and i thought some of you dynamic
font embedders might appreciate it

[code]
package uk.co.thereceptacle.utils { import
flash.errors.IllegalOperationError; /** * text utilities * @author Allandt
Bik-Elliott * @version 1.0 */ public class TextUtils { // constructor public
function TextUtils() { throw new IllegalOperationError(TextUtils is a
static class and should not be instantiated); } // methods /** * converts a
string of characters into a unicode range for font embedding * @param string
*/ public static function traceUnicodeRange(string:String):void { var
unicodeRange:String = ; var ltr:String; for (var i:int = 0; i 
string.length; i++) { if (i  0) unicodeRange += , ; ltr =
string.charCodeAt(i).toString(16); ltr = addLeadingZeros(ltr); unicodeRange
+= U+ + ltr.toUpperCase(); } trace(unicodeRange); } private static
function addLeadingZeros(ltr:String):String { if (ltr.length  4) { ltr =
0 + ltr; ltr = addLeadingZeros(ltr); } return ltr; } } }
[/code]

it's helped me out no end

best
a
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] SOLUTION: converting string to unicode range

2010-04-15 Thread Matt Gitchell
That's excellent, thanks!

On Thu, Apr 15, 2010 at 8:37 AM, allandt bik-elliott (thefieldcomic.com) 
alla...@gmail.com wrote:

 hey guys

 spent a couple of hours googleoogling around to find something to quickly
 convert a string of special characters into a unicode range to no avail so
 i've written a function to do it for me and i thought some of you dynamic
 font embedders might appreciate it

 [code]
 package uk.co.thereceptacle.utils { import
 flash.errors.IllegalOperationError; /** * text utilities * @author Allandt
 Bik-Elliott * @version 1.0 */ public class TextUtils { // constructor
 public
 function TextUtils() { throw new IllegalOperationError(TextUtils is a
 static class and should not be instantiated); } // methods /** * converts
 a
 string of characters into a unicode range for font embedding * @param
 string
 */ public static function traceUnicodeRange(string:String):void { var
 unicodeRange:String = ; var ltr:String; for (var i:int = 0; i 
 string.length; i++) { if (i  0) unicodeRange += , ; ltr =
 string.charCodeAt(i).toString(16); ltr = addLeadingZeros(ltr); unicodeRange
 += U+ + ltr.toUpperCase(); } trace(unicodeRange); } private static
 function addLeadingZeros(ltr:String):String { if (ltr.length  4) { ltr =
 0 + ltr; ltr = addLeadingZeros(ltr); } return ltr; } } }
 [/code]

 it's helped me out no end

 best
 a
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders