Dart – String codeUnits Property

The string property codeunits in Dart programming language returned the list of UTF-16 code of the characters of a string. It is very useful string properties to directly find UTF-16 code units.
 

Syntax: String.codeUnits

Returns: a list of UTF-16 code units

Example 1:
 

Dart



filter_none

edit
close

play_arrow

link
brightness_4
code

// main function start
void main() { 
     
   // initialize string st
   String st = "Geeksforgeeks"
     
   // print the UTF-16 code
   print(st.codeUnits); 
}

chevron_right


Output: 

[71, 101, 101, 107, 115, 102, 111, 114, 103, 101, 101, 107, 115]

Example 2: 
 

Dart

filter_none

edit
close

play_arrow

link
brightness_4
code

// main function start
void main() { 
    
    // initialize string st
   String st = "Computer"
    
   // print the UTF-16 code
   print(st.codeUnits); 
}

chevron_right


Output: 

[67, 111, 109, 112, 117, 116, 101, 114]
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.