PDA

View Full Version : Swift - Unicode Variables/Constants Names


andre
4th June 2014, 08:11 AM
Just been informed by https://twitter.com/ArmstrongAtWork that Swift (Apple's new Programming Language) Variables & Constants names can be formed from Unicode chars.

Here is a relevant extract from Apple's Swift Language Guide
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html


You can use almost any character you like for constant and variable names, including Unicode characters:

let π = 3.14159
let 你好 = "你好世界"
let = "dogcow"

Constant and variable names cannot contain mathematical symbols, arrows, private-use (or invalid) Unicode code points, or line- and box-drawing characters. Nor can they begin with a number, although numbers may be included elsewhere within the name.


Anyone have further info on allowed & non allowed Unicode chars for Swift Variables & Constants names. The restrictions seems a little like IDNA2008

This is initiative is big! Even the ASCII Anglo Saxons will have to switch on to Unicode:)

André 小山 Schappo

andre
4th June 2014, 08:19 AM
Ah! The Emoji did not display correctly in the Quote :(

blastfromthepast
4th June 2014, 02:30 PM
Here we go: 🐶🐮

Tip: Convert to HTML entitites before posting in forum.

Drewbert
4th June 2014, 02:40 PM
Tip: Convert to HTML entitites before posting in forum.

Shouldn't need HTML entities. This forum is supposed to handle unicode natively.

My guess is whatever he cut & pasted it from screwed it up before it got sent from the browser to the forum server.

Drewbert
4th June 2014, 02:52 PM
Trying to hunt down a truetype font that will display these

http://www.iemoji.com/view/emoji/192/nature/dog-face

http://en.wikipedia.org/wiki/Apple_Color_Emoji

blastfromthepast
4th June 2014, 03:03 PM
Shouldn't need HTML entities. This forum is supposed to handle unicode natively.

My guess is whatever he cut & pasted it from screwed it up before it got sent from the browser to the forum server.

It is the database that might be screwing it up. Emoji are beyond the BMP and are coded as two surrogate pairs, which confounds some setups. Check the database and default character encoding.


The full details on database setup: http://mathiasbynens.be/notes/mysql-utf8mb4

blastfromthepast
4th June 2014, 03:18 PM
Trying to hunt down a truetype font that will display these

Symbola.ttf

http://users.teilar.gr/~g1951d/

andre
4th June 2014, 04:44 PM
It is the database that might be screwing it up. Emoji are beyond the BMP and are coded as two surrogate pairs, which confounds some setups. Check the database and default character encoding.


The full details on database setup: http://mathiasbynens.be/notes/mysql-utf8mb4

Which version of MySQL is this forum using? Any version less than 5.5 only has 3 byte utf8 and hence cannot handle chars outside of BMP http://dev.mysql.com/doc/refman/5.5/en/charset-unicode.html

André 小山 Schappo

Ben
4th June 2014, 05:53 PM
Unicode in programming languages ins't anything new. JavaScript for example supports Unicode variables/function names.

Drewbert
4th June 2014, 11:58 PM
Standby 1, we'll work in the SQL problem.

Not urgent, it's hardly like you can register anything with these in it. :^)

Thanks for the pointers, Blast.

blastfromthepast
5th June 2014, 03:34 AM
It could also be vbulletin that is at fault. In cases where the database writing fales, the non BMP data is lost completely, but in this case, we get some garbage characters.

blastfromthepast
9th June 2014, 06:37 PM
😄