Solved Special characters in string

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Jan 19, 2018
18
1
3
How can I put special character such as \r, \f, \b, etc. in a string?

Code:
set {_myString} to "\r"
send {_myString} # outputs "\r"

I want it to output the actual \r (CARRIAGE RETURN) character rather than the literal text "\r", without using skript-mirror if possible.
I know that skript has newline expression for \n, but I don't see any way to put other characters.
 
I don't believe other characters are accepted. Skript is just looking for \n to turn it into a new line. What would you need to use \r for?
 
I don't believe other characters are accepted. Skript is just looking for \n to turn it into a new line. What would you need to use \r for?

I am using it to parse a string that can have escaped characters, inside of Skript.
Please inform me if there is a way to directly do that.
E.g.

Code:
set {_str} to "hello\nthis is the next line\rafter carriage return\nA double right arrow: \u00BB"
broadcast {_str} #output with \ processed as literally '\'
broadcast parseEscape({_str}) #output with \n \r etc. converted to their special character

P.S. What would happen if I read data from a file or website, and it had those special character? Would Skript just ignore them, or convert them to other character?
 
Last edited:
I am using it to parse a string that can have escaped characters, inside of Skript.
Please inform me if there is a way to directly do that.
E.g.

Code:
set {_str} to "hello\nthis is the next line\rafter carriage return\nA double right arrow: \u00BB"
broadcast {_str} #output with \ processed as literally '\'
broadcast parseEscape({_str}) #output with \n \r etc. converted to their special character

P.S. What would happen if I read data from a file or website, and it had those special character? Would Skript just ignore them, or convert them to other character?
You'd have to use an addon to get most of those characters in Skript (I don't know many addons that can get you all the characters, some addons like SkQuery or skUtilities have line break characters, but I can only think of one having them all: skript-reflect / skript-mirror).

The characters are treated as any other character in Skript, the only difference being that you can't actually type it in a string within a script file. This means that if you get the content from a file, website or anything that can have these characters, Skript will treat them as normal characters.
 
Status
Not open for further replies.