🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #14808

Re: Entering unicode (JS)

#14808
From: Peter_Kahrel
Date: Mon, 12 Jan 2004 11:05
18 lines
1333 bytes
Found a solution for this one. You use String.fromCharCode(), but as this takes decimal codes you need to convert a hex code to decimal. So this would do the trick:

uc = "014b";
app.selection[0].contents = String.fromCharCode( hex2dec( uc ) );

Bizarrely, JS has no hex/dec converter, so you'll have to write a function yourself, as below (there are also some converters available on the web):

function hex2dec( h ) {
var h = h.toUpperCase();
var hrev = "";
var d = 0;
var base = "0123456789ABCDEF";
for( var i = 0 ; i < h.length ; i++ )
    hrev = h[i] + hrev;
for( var i = 0 ; i < hrev.length ; i++ )
    d = d + Math.pow(16,i) * base.indexOf(hrev[i])
return d
}
Technical Details
Message-ID: <2ccea61e.1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccea61e.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,cc26865e5febf839
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2004-01-12 03:07:32 PST
From: Peter_Kahrel@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: Entering unicode (JS)
Message-ID: <2ccea61e.1@webx.la2eafNXanI>
Date: Mon, 12 Jan 2004 03:05:58 -0800
References: <2ccea61e.-1@webx.la2eafNXanI>
Lines: 22
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit