Solved

Converting non-western characters into Western character

Posted on 2012-04-12
7
407 Views
Last Modified: 2012-04-16
ReplaceChars.xlsxHi there,

I have started to create a VB script file, that accepts a string of characters and then converts them to a set of predefined conversions.

For example, my spec states that whenever a string contains the following character:

À (Latin Capital Letter A with grave)

I need to replace it with :

A

All in all I have over 190 conversions that I need to complete, and i'm not sure I'm going about it in the best manner, hence i call upon your expertise to guide me.

I've attached a spread sheet, and the code that i've made a start on, any pointers would be greatly appreciated.
convertChars.vbs
0
Comment
Question by:Wayne Atherton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 23

Expert Comment

by:basicinstinct
ID: 37836775
this guy reckons he got it working - it's in VB but would be easy enough to translate to VBScript

http://forums.devshed.com/visual-basic-programming-52/remove-accent-characters-367335.html
0
 
LVL 1

Author Comment

by:Wayne Atherton
ID: 37836846
Hi Basicinstinct,

i converted the code as such:


strIn = Objects("InputString").text

    Dim n
    Dim strMid
    For n = 1 To Len(strIn)
        strMid = Mid(strIn, n, 1)
        Select Case Asc(strMid)
        Case 192 - 197:
            strMid = "A"
        Case 198:
            strMid = "AE"
        Case 199:
            strMid = "C"
        Case 200 - 203:
            strMid = "E"
        Case 204 - 207:
            strMid = "I"
        Case 208:
            strMid = "D"
        Case 209:
            strMid = "N"
        Case 210 - 214, 216:
            strMid = "O"
        Case 215:
            strMid = "x"
        Case 217 - 220:
            strMid = "U"
        Case 221:
            strMid = "Y"
        Case 222, 254:
            strMid = "p"
        Case 223:
            strMid = "B"
        Case 224 - 229:
            strMid = "a"
        Case 230:
            strMid = "ae"
        Case 231:
            strMid = "c"
        Case 232 - 235:
            strMid = "e"
        Case 236 - 239:
            strMid = "i"
        Case 240, 242 - 246, 248:
            strMid = "o"
        Case 241:
            strMid = "n"
        Case 249 - 252:
            strMid = "u"
        Case 253, 255:
            strMid = "y"
        End Select
    Next
        Objects("OutputString").text = strIn + strMid


and entered this string as input:

SpecialÁChar

which resulted in this being returned

SpecialÁCharr

which didn't replace the character, and added an additional 'r' to the end of the string.
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 37836957
you'll have to convert the select case to an if / elseif in vbscript
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Accepted Solution

by:
basicinstinct earned 500 total points
ID: 37836989
ok i made a start for you, but i got to go make the kids school lunches for tomorrow so i'll post what i got up to (223)

Function Englishizer(strIn)
    Dim strOut
    Dim strMid
    Dim x
    Dim n
    For n = 1 To Len(strIn)
        strMid = Mid(strIn, n, 1)
	x = Asc(strMid)
	if x >= 192 and x <= 197 then
		strMid = "A"
	elseif x = 198 then
		strMid = "AE"
	elseif x = 199 then
		strMid = "C"
	elseif x >= 200 and x <= 203 then
		strMid = "E"
	elseif x >= 204 and x <= 207 then
		strMid = "I"
	elseif x = 208 then
		strMid = "D"
	elseif x = 209 then
		strMid = "N"
	elseif (x >= 210 and x <= 214) or x = 216 then
		strMid = "O"
	elseif x = 215 then
		strMid = "x"
	elseif x >= 217 and x <= 220 then
		strMid = "U"
	elseif x = 221 then
		strMid = "Y"
	elseif x = 222 or x = 254 then
		strMid = "p"
	elseif x = 223 then
		strMid = "B"
	end if
        Englishizer = Englishizer & strMid
    Next
End Function

Open in new window

0
 
LVL 1

Author Comment

by:Wayne Atherton
ID: 37837276
ok, i shall give it a bash.
0
 
LVL 1

Author Closing Comment

by:Wayne Atherton
ID: 37837429
Ok, with my simple test, this seems to work fine. I shall port across in UAT and respond if I need anything further.

thanks for you quick response.
0
 
LVL 1

Author Comment

by:Wayne Atherton
ID: 37851319
For anyone else trying to accomplish the very same thing, i've attached the final VBScript for.

thanks for you asssitance basicinstinct - just save the txt file to .vbs
convertChars.txt
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question