Special Characters (ñ á é í ó ú)

Hi!

I need help. When I get information from a text file through createFileInput and cast file.data.toString (), the words in the array do not have special characters like ñ, or accents.

If I use the text () function by passing a string with special characters, it prints the word correctly inside the canvas.

In the html I have included the tag , so I do not know what may be going on.

Answers

  • edited October 2017

    Can you host your sketch in https://OpenProcessing.org/sketch/create
    So we can run it and check what is going wrong as well? L-)

  • I´cant because i need dom elements like "createFileInput".

    I've tried it but I'm not sure if it can be done :(

  • edited October 2017

    There are switches at the right panel which allows us to import pre-defined libraries like "p5.dom.js".
    We can also upload files there as well.

  • Yes but when I insert a dom element it does not appear when running :((

  • edited October 2017
    • Where do you insert your DOM element from? From the ".js" or the ".html" file? :|
    • If it is the latter, indeed https://OpenProcessing.org isn't for your specific sketch.
    • You're gonna need to use something more flexible & complex like for example: https://CodePen.io/
    • Again, w/o access to your sketch's source code, we can't do much anyways. ^#(^
  • edited October 2017

    Ok, I think I got it! :-j

    I'm not sure how to share the project so you can see the code, but I think there you can see the problem.

    https://codepen.io/carambandombolas/full/YrBObb

    Now you just have to load a .txt file that contains words like "año" "piña" or "melocotón" (any with special characters)

  • Answer ✓
    • In order for createFileInput() to correctly load a 'text' file, that file needs to be in UTF-8!
    • If you're on Windows, my advise to you is to install Notepad2: https://xhmikosr.GitHub.io/notepad2-mod/
    • Notepad2 can change the encoding of a 'text' file.
    • Go to: File -> Encoding -> UTF-8. Then CTRL+S to save your file as UTF-8 now.
    • You can even change that editor's default encoding as well. :-bd
Sign In or Register to comment.