Author Topic: Writing quotation marks with a fileObject  (Read 2861 times)

Im stumped,
I need to know how I can write a quotation mark down using a fileObject. For example %fileobject.writeline("blahblah "quote" blahblah");. I do realize that this most likely impossible. I just want to know if anyone has any ideas on how to get around this.

When you want a character in a string to be treated as a raw character just put a backslash before it.

Code: [Select]
%fileobject.writeline("blahblah \"quote\" blahblah");

When you want a character in a string to be treated as a raw character just put a backslash before it.

Code: [Select]
%fileobject.writeline("blahblah \"quote\" blahblah");
I have been living a lie... Thankyou

Full list of escaped characters in TorqueScript (these are case-sensitive):

\' = '
\" = "
\\ = \
\n = Newline (On a console, moves the cursor down one, but NOT to the start of the line.)
\r = Carriage return (On a console, moves the cursor to the start of the line, but NOT down one.)
\t = Horizontal tab
\xHH = ASCII character escape sequence, with two hexadecimal characters specifying the ASCII byte being represented.
\c = Syntax error.

Any other character is (in TorqueScript) unaltered when escaped. Why \c is a syntax error is beyond me.

Full list of escaped characters in TorqueScript (these are case-sensitive):

\' = '
\" = "
\\ = \
\n = Newline (On a console, moves the cursor down one, but NOT to the start of the line.)
\r = Carriage return (On a console, moves the cursor to the start of the line, but NOT down one.)
\t = Horizontal tab
\xHH = ASCII character escape sequence, with two hexadecimal characters specifying the ASCII byte being represented.
\c = Syntax error.

Any other character is (in TorqueScript) unaltered when escaped. Why \c is a syntax error is beyond me.

Because you're supposed to use \cD (D being a decimal digit)? Also, there's several formatting-related ones you missed.

Because you're supposed to use \cD (D being a decimal digit)?

Yes. You can also do \cr to reset the color.

Why \c is a syntax error is beyond me.
It's supposed to indicate a color.

Somehow I had completely forgot that. Huh.

Also, @port: That's (as far as I'm aware) a comprehensive list off all the escaped characters that work properly in TorqueScript.

\*The given character
\xHHASCII character HH (two hexadecimal digits)
\rCarriage return (0x0D)
\nLine feed (0x0A)
\tHorizontal tab (0x09)
\cDBegin color #D (decimal)
\crReset color
\cpPush color, maybe?
\coRestore color, maybe?

Also, the way color codes are handled behind-the-scenes should make any sensible programmer cry in pain.

==>echo("\c1\c2\c3\c4\c5\c6\c7\c8\cr\cp\co" $= "\x02\x03\x04\x05\x06\x07\x0B\x0C\x0F\x10\x11");
1

Yes, you read that right. The color codes OVERWRITE the following ASCII codes: 0x02 - 0x07, 0x0B, 0x0C, and 0x0F - 0x11.

You can't compare against \c0 like this, so I can only assume it's 0x01, but that's how the rest are represented.

<rant>
"But it's just breaking archaic control characters no one —"
NO. If you're going to implement ASCII, you implement loving ASCII.

If you want to have control characters:
  • have it stored in text form,1
  • implement Unicode and use the Private Use Area as your control character,
  • or make your own character encoding and use that instead.
</rant>

1echo(getSubStr("<color:FF800080>", 1, 5));