I have a share link in my game that opens twitter with a pre-written text like so:

OS.shell_open("https://twitter.com/intent/tweet?text=Hello\n\nWorld")

This works fine when I preview my game during development but after I export it the new lines are stripped out so the text is all in a single line.

I also noticed it's stripping away hashtags so I think it's the compiler trying to be clever and removing newlines and # thinking they are comments

Is there any way to prevent this or is it a bug?

Thanks!

  • TwistedTwigleg Surprisingly this still strips the characters out. After posting the issue on github turns out I needed to use uri_encode to properly encode the URL.

You might be able to work around it like this:

“Hello” + String.chr(10) + “world”

Which uses a function in the string to convert a number to its Unicode equivalent. It’s not elegant, but it probably will work.

    DaveTheCoder Thanks but this just encodes the & and ; characters to their url encoded versions.

    TwistedTwigleg Surprisingly this still strips the characters out. After posting the issue on github turns out I needed to use uri_encode to properly encode the URL.

    uri_encode

    I'll just note for reference that in Godot 3.5, the name of that method is http_escape(), and it's a String method.