Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion unicode in string literals
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joe Armstrong  
View profile  
 More options Jul 30 2012, 8:35 am
From: Joe Armstrong <erl...@gmail.com>
Date: Mon, 30 Jul 2012 14:35:50 +0200
Local: Mon, Jul 30 2012 8:35 am
Subject: [erlang-questions] unicode in string literals
What is a literal string in Erlang? Originally it was a list of
integers, each integer
being a single character code - this made strings very easy to work with

The code

    test() -> "a∞b".

Compiles to code which returns the list
of integers [97,226,136,158,98].

This is very inconvenient. I had expected it to return
[97, 8734, 98]. The length of the list should be 3 not 5
since it contains three unicode characters not five.

Is this a bug or a horrible misfeature?

So how can I make a string with the three characters 'a' 'infinity' 'b'

test() -> "a\x{221e}b"        is ugly

test() -> <<"a∞b"/utf8>>   seems to be a bug
                                            it gives an error in the
shell but is ok in compiled code and
                                            returns
<<97,195,162,194,136,194,158,98>> which is
                                            very strange

test() -> [$a,8734,$b]       is ugly

/Joe
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.