How to display special characters in text?

edited August 2017 in How To...

Hi! Right now I'm making a test engine for the SAT. Here's a picture of a question on it. As you can see, instead of "s on both the prompt and the answers, you get the little square boxes for the characters. I'm wondering if there's an easy converter to change the text in a CSV file from what it is currently to UTF-16 encodings which can be used in Processing?

I tried playing around earlier and found that Java/Processing uses "\u221A" instead of just the plain UTF-16 value, but I couldn't find any easy string converters for it earlier. Is there any easier method than me manually replacing the values in the CSV file?

Thanks

Tagged:

Answers

  • There are quotes in the first paragraph, how are they different?

  • Try using a different font. It might just be that the characters are missing from the font you've chosen (and the quotes in the second para are 'smart' quotes whereas the ones in the first are straight)

  • edited August 2017

    It seems to happen with every font I choose (Arial, Serif, Sanserif, Monospace, etc.)

    Also my bad, it wasn't quotes in the first paragraph. It was the copyright sign, and then in the body paragraph it was the — sign. In the answers it was the smart quotes you were talking about, so I guess I'll just replace it in the CSV file. However, things like the copy right sign, —, square root, and others still show the box instead of the character for all text fonts it seems.

    It's strange considering this website says Arial supports the copyright sign, but in Processing it doesn't seem to give. Even when replacing the sign with the UTF line the box doesn't show, but neither does the symbol. Super confused

  • edited August 2017

    Oh thanks! It seems that it's just having trouble in my program specifically, as when creating a new text program for it

    Table exampleTable;
    TableRow exampleRow;
    PFont font;
    String[] texts;
    
    void setup() {
      size(400, 400);
      font = createFont("Arial", 24);
      texts = new String[4];
      exampleTable = loadTable("testTextt.csv");
      for (int i = 0; i < texts.length; i++) {
        exampleRow = exampleTable.getRow(i);
        texts[i] = exampleRow.getString(0);
      }
      printArray(texts);
    }
    
    void draw() {
      background(0);
      textFont(font);
      for (int i = 0; i < texts.length; i++)
       text(texts[i], 50, i * 100 + 50);
    
    }
    

    where the csv lines are

    —here's some text—
    ©_©!!!
    Lines 39-42 (“Normally... community”)
    

    It works fine. I guess I'll make a new thread once I comment my code asking on the Questions about code section :|

  • Alright I figured it out, completely dumb of me. When saving the file if made in excel you have to select .csv UTF-8 and not just .csv

    My bad!

Sign In or Register to comment.