O'Reilly logo

Mastering Julia by Malcolm Sherrington

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Char and strings

So far we have been dealing with numeric and boolean datatypes. In this section we will look at character representation and how Julia handles ASCII and UTF-8 strings of characters. We will also introduce the concept of regular expressions, widely used in pattern matching and filtering operations.

Characters

Julia has a built-in type Char to represent a character. A character occupies 32 bits not 8, so a character can represent a UTF-8 symbol and may be assigned in a number of ways:

julia> c = 'A'
julia> c = char(65)
julia> c = '\U0041'

All these represent the ASCII character capital A.

It is possible to specify a character code of '\Uffff' but char conversion does not check that every value is valid. However, Julia provides an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required