Discuss Scratch
- joefarebrother
-
500+ posts
Unicode blocks
I suggest 2 new blocks to be added to scratch:
Every character that can be stored in a computer has a number associated with it, which is called it's “unicode codepoint”. Whenever it stores a character, it's actually storing this codepoint. (You may have also heard of ASCII, that's a much smaller set of characters which is backwards compatible with unicode, which contains the Latin alphabet, Arabic digits, and some symbols). Unicode includes characters from lots of different languages, as well as mathematical symbols, emojis, and more. Most programing languages have ways to convert between characters and numbers (some only support ASCII, but many support full unicode), but scratch doesn't. Snap!, a scratch mod, does.
If you passed in an invalid codepoint, it could return an empty string, and if you pass in more than one character it could return NaN or -1
Note that this is the unicode codepoint, and not dependent on any particular encoding, i.e. UTF8 or UTF16)
Why would it be useful to convert between numbers and characters? Well, firstly you could do case sensitive =, as the unicode of A is 65, but of a it's 97, so you can do
You could check if something is an uppercase letter, lowercase letter, digit, or something else by checking the relevant ranges, without having to have a list for different types if symbols and do contains as that's inefficient
You could implement a simple case converter:
(I say simple because it only deals with ASCII, i.e. English letters)
You could use newlines in text without hacked blocks:
It would also be VERY useful for things like cloud list engines where you need to encode text as numbers. Usually you have to have a string containing all the characters, and search through it when you need to encode a character, and some trick to get it to compare case sensitively, which is inefficient and obviously doesn't support all unicode characters.
There is no workaround (only a partial workaround I just described, which might work for ASCII, but certainly not for unicode)
If you're thinking “But that might be confusing, not everyone would understand it or need it” - same thing is true for the trigonometry blocks. The point of Scratch is to learn programming, and this is a feature most programming languages have.
The ST could change the names to something more understandable if needed.
(convert number (65) to symbol :: operators) // returns A
(convert symbol [A] to number :: operators) // returns 65
Every character that can be stored in a computer has a number associated with it, which is called it's “unicode codepoint”. Whenever it stores a character, it's actually storing this codepoint. (You may have also heard of ASCII, that's a much smaller set of characters which is backwards compatible with unicode, which contains the Latin alphabet, Arabic digits, and some symbols). Unicode includes characters from lots of different languages, as well as mathematical symbols, emojis, and more. Most programing languages have ways to convert between characters and numbers (some only support ASCII, but many support full unicode), but scratch doesn't. Snap!, a scratch mod, does.
If you passed in an invalid codepoint, it could return an empty string, and if you pass in more than one character it could return NaN or -1
Note that this is the unicode codepoint, and not dependent on any particular encoding, i.e. UTF8 or UTF16)
Why would it be useful to convert between numbers and characters? Well, firstly you could do case sensitive =, as the unicode of A is 65, but of a it's 97, so you can do
<(convert symbol [A] to number :: operators ) = (convert symbol [a] to number :: operators )> // returns false
You could check if something is an uppercase letter, lowercase letter, digit, or something else by checking the relevant ranges, without having to have a list for different types if symbols and do contains as that's inefficient
You could implement a simple case converter:
set [letter num v] to (convert symbol (letter) to number :: operators )
If <<(letter num) > [64]> and <(letter num) < [91]>>
set [letter v] to (convert number ((letter num) + (32)) to symbol :: operators ) // to lowercase
(I say simple because it only deals with ASCII, i.e. English letters)
You could use newlines in text without hacked blocks:
Say (join [hello] (join (convert number (10) to symbol ::operators ) [world!]))
It would also be VERY useful for things like cloud list engines where you need to encode text as numbers. Usually you have to have a string containing all the characters, and search through it when you need to encode a character, and some trick to get it to compare case sensitively, which is inefficient and obviously doesn't support all unicode characters.
There is no workaround (only a partial workaround I just described, which might work for ASCII, but certainly not for unicode)
If you're thinking “But that might be confusing, not everyone would understand it or need it” - same thing is true for the trigonometry blocks. The point of Scratch is to learn programming, and this is a feature most programming languages have.
The ST could change the names to something more understandable if needed.
Last edited by Paddle2See (Aug. 28, 2023 15:47:01)
- Meep5010
-
100+ posts
Unicode blocks
when [good v] Idea posted::events hat
forever
type [SUPPORT!]::looks
end
SUPPORT!
SUPPORT!
SUPPORT!
(and so on)
Last edited by Meep5010 (May 30, 2016 20:57:23)
- Scratcher1002
-
1000+ posts
Unicode blocks
Support I guess. I'd see this being used, but I'm not quite sure how to make a unicode symbol..
- jokebookservice1
-
1000+ posts
Unicode blocks
With that phrasing the block's purpose is obvious. I therefore will write some blockspam to show my support
when green flag clicked
set [text v] to (convert number (This should return nothing) to symbol ::operators)
set [text v] to (join (text) (convert number (83) to symbol ::operators))
set [text v] to (join (text) (convert number (117) to symbol ::operators))
set [text v] to (join (text) (convert number (112) to symbol ::operators))
set [text v] to (join (text) (convert number (112) to symbol ::operators))
set [text v] to (join (text) (convert number (111) to symbol ::operators))
set [text v] to (join (text) (convert number (114) to symbol ::operators))
set [text v] to (join (text) (convert number (116) to symbol ::operators))
set [text v] to (join (text) (convert number (33) to symbol ::operators))
say (text)
Last edited by jokebookservice1 (May 30, 2016 21:27:14)
- JGames101
-
100+ posts
Unicode blocks
I support. This would be an AMAZING addition. Again, Full support!
- walkcycle
-
500+ posts
Unicode blocks
Why? I support. This would be an AMAZING addition. Again, Full support!
- kenny2scratch
-
500+ posts
Unicode blocks
Mmph… I would semi-support this if it weren't for the fact that this would be case-sensitive. Just for that, full support! 

- Zekrom01
-
1000+ posts
Unicode blocks
Good idea, but I don't see many uses for these blocks besides decoding/encoding strings.
- Randomness-TV
-
100+ posts
Unicode blocks
No support. My main reason is that not many users know Unicode.
Last edited by Randomness-TV (June 13, 2017 12:41:59)
- sprands
-
100+ posts
Unicode blocks
not many users know Unicode.It would be useful for people who do know Unicode, and even that's aside from the fact that you can just Google the unicode equivalent of a letter, or the letter equivalent of a unicode number, and BAM, Wikipedia or Google has a chart or something. No support. My main reason is that
Also, it would generally be useful for a pretty easy password system. It would allow case sensitive passwords, by creating a variable that holds characters. Each character is sent to the variable one by one, and converted to unicode, and if the character equals a certain unicode character, the system continues to check.
Overall, the unicode blocks would be easy to research, and useful for security, as well as a whole plethora of things i don't think I know about.
- titanscratch
-
100+ posts
Unicode blocks
Absolutely no-support! A lot of New-scratchers (and Scratchers) don't know Unicode. And this suggestion would make Scratch too complicated. Even I don't know Unicode! So no support!
- Inb4
-
100+ posts
Unicode blocks
Unicode is quite simple to learn. Quoting the message before that you didn't read… Absolutely no-support! A lot of New-scratchers (and Scratchers) don't know Unicode. And this suggestion would make Scratch too complicated. Even I don't know Unicode! So no support!
It would be useful for people who do know Unicode, and even that's aside from the fact that you can just Google the unicode equivalent of a letter, or the letter equivalent of a unicode number, and BAM, Wikipedia or Google has a chart or something.
Also, it would generally be useful for a pretty easy password system. It would allow case sensitive passwords, by creating a variable that holds characters. Each character is sent to the variable one by one, and converted to unicode, and if the character equals a certain unicode character, the system continues to check.
Overall, the unicode blocks would be easy to research, and useful for security, as well as a whole plethora of things i don't think I know about.
- turkey3
-
1000+ posts
Unicode blocks
I'd say support. But I thought unicode values looked something like U+000F and such. How do you find the single number for a char in Unidode, because I certainly cannot read hex and I can't read the character code either since it doesn't seem to be a simple digit.
For instance, what is unicode for “5”?
For instance, what is unicode for “5”?
- joefarebrother
-
500+ posts
Unicode blocks
They don't have to look like hex, because what a unicode codepoint really is is just a number, and hex is just one way of writing it. I'd say support. But I thought unicode values looked something like U+000F and such. How do you find the single number for a char in Unidode, because I certainly cannot read hex and I can't read the character code either since it doesn't seem to be a simple digit.
For instance, what is unicode for “5”?
The codepoint of the character ‘5’ is 53.
- stickfiregames
-
1000+ posts
Unicode blocks
A hex number is still a number. In your example 0x000F is equal to 15, and the Unicode for “5” is U+0035 which is decimal 53. Unicode codepoints are written in hex by convention, but this block would return a number and so it would be displayed in decimal because that's how Scratch displays all numbers. I'd say support. But I thought unicode values looked something like U+000F and such. How do you find the single number for a char in Unidode, because I certainly cannot read hex and I can't read the character code either since it doesn't seem to be a simple digit.
For instance, what is unicode for “5”?
- ev3coolexit987654
-
1000+ posts
Unicode blocks
FULL SUPPORT! To the people who say it's too hard, you don't have to know it. Just experiment, and google. You don't have to use it if you don't want to. This could have so many uses
- walkcycle
-
500+ posts
Unicode blocks
Could a Scratch list hold the number of characters in a Unicode set?