Re: Is there a handy way to declare Rune literals?

2018-10-20 Thread doofenstein
instead of using a macro, you could also use a template, which is imho the better way, since it's a less powerful construct and easier readable: import unicode template uc(s: static[string]): Rune = const runeVal = runeAt(s, 0) runeVal Run

Re: Is there a handy way to declare Rune literals?

2018-10-20 Thread vsajip
Those are very handy idioms to know, thanks!

Re: Is there a handy way to declare Rune literals?

2018-10-19 Thread Hlaaftana
You can partly achieve this for double quoted strings with the raw string call syntax: import unicode template u(s: string): seq[Rune] = toRunes(s) echo u"abcd" Run I don't think you can do the same with single quoted strings, however you can

Re: Is there a handy way to declare Rune literals?

2018-10-19 Thread vsajip
Well, I could just do `Rune('.')` which also works, without the need for `ord()`, but I'm looking to see if there's something more compact like `u'.'` or similar.

Re: Is there a handy way to declare Rune literals?

2018-10-19 Thread Tiberium
Since Unicode contains all ASCII characters you can easily do that: import unicode let my_rune = Rune(ord('.')) echo my_rune Run

Is there a handy way to declare Rune literals?

2018-10-19 Thread vsajip
If one is looking through Unicode text and wants to compare a given rune with some literal value like '.' or ',', is there any easy way of declaring ASCII char values as Rune literals so that they can be compared more readably than doing `if some_rune == Rune('.')` or similar? Something like