1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Em Dash in Strings (SOLVED)

Discussion in 'Programming' started by Fixer90, Nov 14, 2019.

  1. Fixer90

    Fixer90 Member

    Joined:
    Nov 17, 2016
    Posts:
    145
    I want to include em dashes in my strings, and not have them return as the default "▯." For example:
    Code:
    str = "The quick brown fox — who was very quick indeed — jumped over the lazy dog.";
    returns as
    Code:
    "The quick brown fox ▯ who was very quick indeed ▯ jumped over the lazy dog."
    I already tried changing the range of the font to ASCII 32-255.
     
  2. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    463
    The em-dash is not included in the ASCII character set. You'll have to use Unicode. Its character code is U+2014.
     
  3. Fixer90

    Fixer90 Member

    Joined:
    Nov 17, 2016
    Posts:
    145
    I just tried using chr(2014), and it still returned the "▯" character, despite chr being a function that returns a string from the input Unicode number.
     
  4. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,947
    Does the font you're using contain a glyph for this character? If not, the placeholder will be used.

    That aside, the 2014 is in hex. That's 8212 in decimal.
     
    Fixer90 likes this.
  5. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    463
    Unicode character codes are in hexadecimal. You should either use chr(8212) or chr(0x2014).
     
    Fixer90 likes this.
  6. Fixer90

    Fixer90 Member

    Joined:
    Nov 17, 2016
    Posts:
    145
    Didn't work for both Arial and Verdana. I'll try other fonts, but could it be out of the range? I'm still kinda new to character codes, Unicode, ASCII, how they relate, etc.
     
  7. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    463
    It's in both. What you need to do is add a new range in your font from 8212-8212. This will include just the em-dash. Then it should display properly when you try to draw it.
     
    Fixer90 likes this.

Share This Page