Jump to content
UBot Underground

Have You Ever Seen These Strange Text Characters [Solution Here]


Recommended Posts

Check out this code snippet.

clear list(%words)
set(#var,"Congressman Adam ‘Shifty’ Schiff Strikes Again","Global")
add list to list(%words,$list from text($words(#var),$new line),"Don\'t Delete","Global")
set(#var,$replace(%words,"
"," "),"Global")

Do you see the odd characters in the 2nd line?

 

Unfortunately, there is not a function in UBot to strip those out.  I will likely add this to the tracker

as an enhancement request and cross my fingers that it gets accepted.

 

The 3rd line I adapted from the UBot Wiki page http://wiki.ubotstudio.com/wiki/Words

This function, used in this manner, adds each word to the List %words

But if you look at the list once it is created you will see that those funky characters are no longer

there.

 

So now, I rebuilt that sentence in the 4th line and you will see that those characters do not appear.

 

Yeah I know.  I could have used Regex but sometime it's nice to just stick with a text function

or a quick work around in my case.

 

Later,

 

UBotBuddy

 

Link to post
Share on other sites

‘ is a left single quotation mark

’ is a right side quotation mark

 

 

the problem is with the encoding and decoding

if the page that its obtained from is incorrect its going to be scraped as the above.

 

fix for ubot

we can do a regex replace to remove things, or a simple replace around it to replace the left and right side properly before reading in.

it has to decode UTF-8 first, then decode the ISO 1252 encoding that produces the encoded characters shown.

 

set(#var,"Congressman Adam ‘Shifty’ Schiff Strikes Again","Global")

comment("2 replace functions used to replace the characters")
set(#var2,$replace($replace("Congressman Adam ‘Shifty’ Schiff Strikes Again","‘","\'"),"€™","\'"),"Global")

comment("We replace the second one first ’ otherwise †would be removed from the second one before it removes the ™")
set(#var3,$replace regular expression("Congressman Adam ‘Shifty’ Schiff Strikes Again","(’|â€)","\'"),"Global")

ui stat monitor("Original:",#var)
ui stat monitor("2 replace functions:",#var2)
ui stat monitor("Regex Replace:",#var3)

Link to post
Share on other sites

You are correct.

 

But I was looking for a solution to totally remove those characters.  There are too

many of those fancy text accents for my taste so I am into ripping them out rather

than replacing them.

 

lol

 

Buddy

Link to post
Share on other sites

I added this to my list of small things that don't fit anywhere else. Which is a plugin I'll eventually make once I have enough of these kinds of things. In the meantime I used another newer function called $to sentence to shorten it up a bit.

set(#var,$to sentence($list from text($words("Congressman Adam ‘Shifty’ Schiff Strikes Again"),$new line)),"Global")
  • Like 1
Link to post
Share on other sites

LOL  Thanks guy!

 

I left my code that way so newbies could see what was going on.  Sometimes command

stacking confuses new learners.

 

@HelloInsomnia

 

Let me know when you are ready to test out that plugin.  I would like to be one of your

testers.

 

Buddy

  • Like 1
Link to post
Share on other sites
  • 2 weeks later...

LOL  Thanks guy!

 

I left my code that way so newbies could see what was going on.  Sometimes command

stacking confuses new learners.

 

@HelloInsomnia

 

Let me know when you are ready to test out that plugin.  I would like to be one of your

testers.

 

Buddy

 

I hate that nested stuff, not really HInsomnia's example but that stuff with 2 or 3 nested nodes, inside a comparison operator making overall around 6 nested nodes, absolute madness, with ubots UI nodeview its just not easy to read, especially when you go trying to fix a bug 2 months after you written it and cant remember how it works, if your moving around scroll bars to see into a tiny little window to try and debug your code, your doing it wrong and yet we've all been there I'm sure!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...