Solved

Converting non-western characters into Western character

Posted on 2012-04-12
7
405 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
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!

 
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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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