🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20607

VB: Getting Unicode values

#20607
From: Olav Kvern
Date: Fri, 14 Jun 2002 20:30
37 lines
2454 bytes
Gang-- 

If you've ever wanted to get all of the characters in the selected text as a sequence of Unicode strings, you might find the following of interest. Make youself a form with a multi-line text field, then put this under a 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 = "" 
����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 
End If 
 

Note that some break characters are converted into returns, but everything else seems to come across OK. 

Thanks, 

Ole
Technical Details
Message-ID: <ef9225b.-1@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-08!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,10c1e4792a0aa4e9,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-06-14 13:44:05 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-08!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: VB: Getting Unicode values
Message-ID: <ef9225b.-1@WebX.aaQKaf7vad4>
Date: Fri, 14 Jun 2002 13:30:05 -0700
Lines: 44
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit