Article View: adobe.scripting.indesign
Article #19733VB: Finding Unicode String Values
From: Olav Kvern
Date: Tue, 26 Nov 2002 19:41
Date: Tue, 26 Nov 2002 19:41
45 lines
2702 bytes
2702 bytes
Gang--
I could swear I've posted this before, but I'll do so again because of the recent questions about special characters. Make yourself a form with a text field and a button. Put the following under the button:
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
If myInDesign.Documents.Count > 0 Then
Set myDocument = myInDesign.ActiveDocument
Set mySelection = myInDesign.Selection
If mySelection.Count > 0 Then
Set myText = mySelection.Item(1)
myString = ""
If myText.Characters.Count > 1 Then
Set myCharacter = myText.Characters.ItemByRange(myText.Characters.Item(1), myText.Characters.Item(myText.Characters.Count)).Item(1)
myContents = myCharacter.TextContents
For myCounter = 1 To Len(myContents)
myCharacter = Mid(myContents, myCounter, 1)
If AscW(myCharacter) < 0 Or AscW(myCharacter) > 255 Then
myString = myString & "<" & CStr(Hex(AscW(myCharacter))) & ">"
Else
myPadString = ""
myLength = 4 - Len(CStr(Hex(AscW(myCharacter))))
For myPadCounter = 1 To myLength
myPadString = myPadString & "0"
Next
myString = myString & "<" & myPadString & Hex(AscW(myCharacter)) & ">"
End If
Next
Text1.Text = myString
End If
Else
MsgBox "Please select two or more characters. If you select a single character, InDesign will return the idSpecialCharacters enum decimal value, which won't work."
End If
End If
Select two or more characters in InDesign, then click the button. The script will put the Unicode strings for the selected characters into the text field.
Thanks,
Ole
Technical Details
Message-ID:
<1de6c4e7.-1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.esat.net!diablo.theplanet.net!diablo.netcom.net.uk!netcom.net.uk!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,3ebab7cfc9a1623e,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-11-26 12:07:56 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.esat.net!diablo.theplanet.net!diablo.netcom.net.uk!netcom.net.uk!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: VB: Finding Unicode String Values Message-ID: <1de6c4e7.-1@WebX.la2eafNXanI> Date: Tue, 26 Nov 2002 11:41:28 -0800 Lines: 50 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit