Converting XML text structure with encoded markup characters

Help with writing and playing macros

Converting XML text structure with encoded markup characters

Postby ThWiedmann » Mon Nov 15, 2010 1:43 am

Hello,

the following xml text structure has encoded markup signs:

%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3C ...

[How] can this xml text structure be imported or converted in UltraEdit to be displayed as decoded XML text without encoded markups?

I'm working with version 11.10c+1.

Thomas Wiedmann
User avatar
ThWiedmann
Basic User
Basic User
 
Posts: 17
Joined: Sun Jul 31, 2005 11:00 pm

Re: Converting XML text structure with encoded markup characters

Postby Mofi » Mon Nov 15, 2010 2:16 am

Your version of UE does not support scripts. With a script it would be very easy to search for %[0-9A-F][0-9A-F] and convert the hexadecimal value of the encoded characters to characters.

So you have to use a macro for that job with the macro property Continue if a Find with Replace not found checked for this macro.

InsertMode
ColumnModeOff
HexOff
UnixReOff
Find MatchCase "%22"
Replace All """
Find MatchCase "%3C"
Replace All "<"
Find MatchCase "%3D"
Replace All "="
Find MatchCase "%3E"
Replace All ">"
Find MatchCase "%3F"
Replace All "?"

Edited on 2010-11-27: More easily is to select the encoded text and use command HTML Decode from the HTML toolbar.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Converting XML text structure with encoded markup characters

Postby ThWiedmann » Tue Nov 16, 2010 6:47 am

Thanks for this hint. Again and again I'm surprised about the features of UltraEdit. I still added some statements.
So for all, who'll have a similar task sometime, here's my macro script DecodeMarkups:

InsertMode
ColumnModeOff
HexOff
UnixReOff
Find "%0A"
Replace All "^n"
Find "+"
Replace All " "
Find "%21"
Replace All "!"
Find "%22"
Replace All """
Find "%26"
Replace All "&"
Find "%28"
Replace All "("
Find "%29"
Replace All ")"
Find "%2C"
Replace All ","
Find "%2F"
Replace All "/"
Find "%3A"
Replace All ":"
Find "%3B"
Replace All ";"
Find "%3C"
Replace All "<"
Find "%3D"
Replace All "="
Find "%3E"
Replace All ">"
Find "%3F"
Replace All "?"
Find "%5B"
Replace All "["
Find "%5C"
Replace All "\"
Find "%5D"
Replace All "]"
User avatar
ThWiedmann
Basic User
Basic User
 
Posts: 17
Joined: Sun Jul 31, 2005 11:00 pm


Return to Macros