2

A true dev rant now: I find it difficult to get Unicode working. There is a nice assignment in a book where you have to insert a balloon emoji on the page.

Okay, easy enough. So I use <meta charset="UTF-8"> and then the HTML entity &#x1F388; which works, but then in JavaScript it doesn't work:

<div id="output"></div>
<script>
let balloon = '\u1F388';
document.getElementById("output").textContent = balloon;
</script>
Either I don't have the right font, or something else is going on.

And now more research. This is what I find cumbersome about Computer Science; hours stuck on one single thing. lol

Comments
  • 0
    25 minutes later and I figured it out:

    -> It's a UTF-8 combination character; one of those more modern extended set characters that requires you to type two Unicode characters together in order to be parsed:

    /* solution */

    let balloon = '\uD83C\uDF88';

    Previous research:

    https://fileformat.info/info/...

    This tells me it is only supported by certain fonts, so I tried Segoe UI Emoji; no luck. charmap didn't show a balloon either.

    https://emojipedia.org/balloon/...

    emojipedia not much info.

    Finally, emojiterra explains it:

    https://emojiterra.com/balloon/

    Good thing I read about it in an earlier book or I would have been a bit more lost. lol.

    Question: does this emoji really need two UTF-8 codepoints or just one? lol
  • 2
    You could also just
    let balloon = '🎈';
  • 0
    @Lensflare but then I don't learn about web fundamentals. lol
  • 1
    @CaptainRant that’s not really web fundamentals.
  • 0
    I think Swift and Rust might be the only main stream languages which get utf-8 right.
  • 2
    @Lensflare haha literally exactly what i wanted to say.
  • 2
    @Lensflare boooh, C:

    int main(){

    printf("%s\n", "🎈");

    return 0;

    }

    Works just fine.
  • 1
    @retoor I don’t mean utf-8 support in code. That even JS can do, as I pointed out.

    What I mean is wrong counting of utf8 characters.
    Go ahead and ask js or C how many characters "🎈" is. If it says it‘s more than 1, it’s wrong.

    I had to intentionally make the character counting function broken in JoyRant to have the same counting as the devrant backend has.

    And that is also the reason why link underlines are fucked up in JoyRant.
  • 2
    @Lensflare i'm surprised it even compiled. But this is the way how to test that on C, don't even have to count:

    ```

    retoor@retoor2:~$ gcc balloon.c

    balloon.c: In function ‘main’:

    balloon.c:4:20: warning: multi-character character constant [-Wmultichar]

    4 | printf("%c\n", '🎈');

    | ^~~~

    retoor@retoor2:~$ ./a.out

    �

    ```

    tsoding has a nice episode out of this.
  • 2
    @Lensflare and python since version 3:

    ```

    In [1]: len("🎈")

    Out[1]: 1

    ```
  • 0
    @retoor Python definitely surprised me with that one! 😅
  • 1
    @retoor mentions seem to be broken again. shit.
    This time I fear they might stay broken, like images.
  • 0
    @Lensflare The web uses the HTTP protocol on top of the TCP protocol, where the point of the web is to transfer known resources between machines. In order to correctly serialize that data, you need UTF-8. I would say it is part of web fundamentals.
  • 0
    @CaptainRant not what I meant.

    Learning how to use escaping to represent multi character emojis is not what I would call fundamental knowledge of how the web works or how web development works.
Add Comment