Link to home
Start Free TrialLog in
Avatar of fpoyavo
fpoyavoFlag for United States of America

asked on

Unprintable characters

Hi Experts,

I am using as an input file (txt or xml) having unprintable characters in it. The nature of these characters is "foreign words or letters". Any solution to get rid of them I mean replace with equvivalent English ones ? I can use VB, VBScript, Java, JavaScript.

Thank you.
Avatar of cookre
cookre
Flag of United States of America image

To simply get rid of them:

for each line:
for i=1 to len(currentline)
    if asc(mid(currline,i,1))<20  or asc(mid(currline,i,1))>127 then mid(currline,i,1)=" "   ' or whatever char you want
    next i
Oops, the '20' above should have been '31'.


Replacing them would be a bit problematic.

For example, if you suspect Russian, some characters would have to be transliterated into as many as four latin character.

If you simply presume a latin character set, then the easiest thing to to would be to set up a translation table that maps the extended characters (asc() values greater than 127 down to whichever English character you want.

For example:

(again, for each line):

for i=1 to len(currline)
     select case asc(mid(currline,i,1))
              case 0 to 31
                      mid(currline,i,1)=Xlatetable(asc(mid(currline,i,1)))
              case is>127
                      mid(currline,i,1)=Xlatetable(asc(mid(currline,i,1)))
             end select
      next i

xlatetable is an array you would have to set up where xlatetable(N) is the character you want to use when asc(mid(currline,i,1) equals N.

ASKER CERTIFIED SOLUTION
Avatar of Kavar
Kavar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fpoyavo

ASKER

Kavar,

I am getting error in this line : (FilePath,1,0,1) --- > message : "invalid procedure call"

??? Any idea ?

Avatar of fpoyavo

ASKER

I fixed that. But another thing is when I write to output it does not like it.
Avatar of fpoyavo

ASKER

I got it.
Avatar of Kavar
Kavar

just so I know what was going wrong, what was happening?