Dart: Runes

# String.codeUnitAt() Function

String.codeUnitAt(int index);

 Returns the 16-bit UTF-16 code unit at the given index.

Example

import 'dart:core'; 
void main(){ 
   f1(); 
} 
f1() { 
   String x = 'Runes'; 
   print(x.codeUnitAt(0)); 
}

=> output

82

# String.codeUnits Property

This property returns an unmodifiable list of the UTF-16 code units of the specified string.

String. codeUnits;

Example

import 'dart:core';  
void main(){ 
   f1(); 
}  
f1() { 
   String x = 'Runes'; 
   print(x.codeUnits); 
} 

=> output

[82, 117, 110, 101, 115]

# String.runes Property

This property returns an iterable of Unicode code-points of this string.Runes extends iterable.

String.runes

Example

void main(){ 
   "A string".runes.forEach((int rune) { 
      var character=new String.fromCharCode(rune); 
      print(character); 
   });  
} 

It will produce the following output −

A 
s 
t 
r 
i 
n 
g

Leave a Reply

Your email address will not be published. Required fields are marked *