Solved

Converting non-western characters into Western character

Posted on 2012-04-12
7
398 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

825 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