Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Why can't I use emojis with the letter X of Y reporter?
- ninjaMAR
-
1000+ posts
Why can't I use emojis with the letter X of Y reporter?
I can set a variable to be an emoji, but using the letter X of Y block on an emoji returns an error symbol instead of the emoji. A demo is available @ https://scratch.mit.edu/projects/1030802587/
Last edited by ninjaMAR (June 2, 2024 12:30:30)
- awesome-llama
-
1000+ posts
Why can't I use emojis with the letter X of Y reporter?
Inside where?
I've used emojis and special characters in list/variable names and their data, they all work fine.
I've used emojis and special characters in list/variable names and their data, they all work fine.
- ninjaMAR_alt
-
14 posts
Why can't I use emojis with the letter X of Y reporter?
(#2)Sorry, upon closer investigation, it seems that the letter X of Y block doesn't work at all with emojis. See https://scratch.mit.edu/projects/1030802587/
Inside where?
I've used emojis and special characters in list/variable names and their data, they all work fine.
- CST1229
-
1000+ posts
Why can't I use emojis with the letter X of Y reporter?
Basically: JavaScript (the programming language Scratch uses) stores text using UTF-16 encoding, which means characters take up 2 bytes each. These pairs of 2 bytes are called “code units”.
This can represent characters up to Unicode code point U+FFFF, which is everything in the Basic Multilingual Plane (or BMP for short). Anything above that is represented using multiple code units, and as such count as multiple characters to JavaScript (as properly counting characters would require iterating the text to look for split codepoints, which is more performance-intensive). Therefore, they also count as multiple letters to Scratch's “letter of” block.. Emojis are outside the BMP, so they get split. If you e.g take letters 1 and 2 of an emoji, and join them together, you get the full emoji again.
This can represent characters up to Unicode code point U+FFFF, which is everything in the Basic Multilingual Plane (or BMP for short). Anything above that is represented using multiple code units, and as such count as multiple characters to JavaScript (as properly counting characters would require iterating the text to look for split codepoints, which is more performance-intensive). Therefore, they also count as multiple letters to Scratch's “letter of” block.. Emojis are outside the BMP, so they get split. If you e.g take letters 1 and 2 of an emoji, and join them together, you get the full emoji again.
Last edited by CST1229 (June 2, 2024 12:51:45)
- ninjaMAR
-
1000+ posts
Why can't I use emojis with the letter X of Y reporter?
(#4)Thank you
Basically: JavaScript (the programming language Scratch uses) stores text using UTF-16 encoding, which means characters take up 2 bytes each. These pairs of 2 bytes are called “code units”.
This can represent characters up to Unicode code point U+FFFF, which is everything in the Basic Multilingual Plane (or BMP for short). Anything above that is represented using multiple code units, and as such count as multiple characters to JavaScript (as properly counting characters would require iterating the text to look for split codepoints, which is more performance-intensive). Therefore, they also count as multiple letters to Scratch's “letter of” block.. Emojis are outside the BMP, so they get split. If you e.g take letters 1 and 2 of an emoji, and join them together, you get the full emoji again.
- Discussion Forums
- » Questions about Scratch
-
» Why can't I use emojis with the letter X of Y reporter?