Solved

Converting non-western characters into Western character

Posted on 2012-04-12
7
393 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now