Author Topic: Special Characters in a String  (Read 10519 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Special Characters in a String
« on: 2012-06-16, 07:36:46 PM »
So due to a question I had about using special characters in messages I found out that:

You can decide the character by typing \u001 or \u002

Where 001 is the value of the tile in the project.

002 would go to the 3rd tile because it is of a zero based index.

I hope this helps some of the new members.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Special Characters in a String
« Reply #1 on: 2012-06-16, 08:21:09 PM »
You can also go into the message editor and click the "..." button at the end of the text field, and then it will let you click on whatever image you want to insert.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Special Characters in a String
« Reply #2 on: 2012-07-08, 01:00:53 PM »
Ok, so I'm trying to use Special Characters in a DebugLabel type situation, but even though I copy and paste the code ex:\u0084 from the Extended Characters Selector, it shows only as a question mark when the string is drawn to the screen at runtime. Is there a reason to this?

EDIT: I found that DrawText uses GraphicsSheets instead of tiles. This means I'll have to either create a new sheet because my images and special characters are larger, or find a way to let the DrawText function use Tilesets...
« Last Edit: 2012-07-09, 03:14:24 PM by #Sharp »

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Special Characters in a String
« Reply #3 on: 2012-07-12, 06:44:39 PM »
http://oreilly.com/actionscript/excerpts/as3-cookbook/appendix.html

I found this link which explains the irregularity between the font and the characters through unicode escape, but say, I extended my graphic sheet from 4 rows to 30 rows, how would I determine the unicode escape sequence for characters like that?


EDIT: Pffft, problem solved by changing from Ascii to UTF32..... I should really crack open a book sometime about these things.
« Last Edit: 2012-07-13, 02:16:07 PM by #Sharp »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Special Characters in a String
« Reply #4 on: 2012-07-14, 07:38:09 AM »
Why is this complicated? If you are using unicode escape sequences, you have 4 hex digits to work with, so you can access 65535 characters. You can use windows calculator to convert between decimal and hexadecimal if you switch it to scientific view. Am I missing something?

Oh... are you talking about this line in DrawText?
Code: [Select]
byte[] charBytes = System.Text.Encoding.ASCII.GetBytes(text);
Yeah, it is limited to ASCII in that sense. Yeah, if you want to access more than 255 values, you would need to replace the ASCII encoder with something that can handle more than 1 byte per character. UTF-32 would probably work. But I assume you wouldn't be dealing with 4 billion characters, so you wouldn't need the 4 bytes per characters that it uses. You might be better off using the Unicode encoding (which is UTF-16). Unless you're using something like this:
Code: [Select]
char.ConvertToUtf32(text, charIdx)which makes the conversion really easy without having to even call on an encoder.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Special Characters in a String
« Reply #5 on: 2012-07-14, 09:14:49 AM »
Haha, I was about to ask about UTF-16. I was reading on StackOverflow about the advantages and disadvantages of using each. When Using ASCII, it defaulted any char value too large to the "?" character, my initial source of confusion.