- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Runes in Dart Programming
We know that strings in Dart are a sequence of Unicode UTF-16 characters. Dart Runes are actually UTF-32 Unicode code points.
They are UTF-32 string which is used to print special symbols.
For example, the theta symbol in dart is displayed when we assign the Unicode equivalent value of '\u0398' to a variable.
Example
Consider the example shown below −
void main(){ var heartSymbol = '\u0398'; print(heartSymbol); }
Output
Θ
There are different methods/properties that we can apply on dart Runes to extract the string core units. These mainly are −
string.codeUnitAt()
string.codeUnits
string.runes
string.codeUnitAt()
The string.codeUnitAt() method is used to access the character's code unit that is present inside the string. It takes one argument, the position(index) we want to get the code unit of.
Example
Consider the example shown below −
void main(){ String name = "tutorialspoint"; print(name.codeUnitAt(0)); }
In the above code, we are printing the character unit at the 0th index of the string named name.
Output
116
string.codeUnits property
The string.codeUnits property is used to print the character units of each character in a string.
Example
Consider the example shown below −
void main(){ String name = "tutorialspoint"; print(name.codeUnits); }
Output
[116, 117, 116, 111, 114, 105, 97, 108, 115, 112, 111, 105, 110, 116]
string.runes property
The string.runes property of a string class is used to iterate the given string through the UTF-16 code unit.
Example
Consider the example shown below −
void main(){ String name = "tutorialspoint"; name.runes.forEach((int rune){ print(rune); }); }
Output
116 117 116 111 114 105 97 108 115 112 111 105 110 116
- Related Articles
- Comments in Dart Programming
- Constructors in Dart Programming
- Enumerations in Dart Programming
- Functions in Dart Programming
- Immutability in Dart Programming
- Inheritance in Dart Programming
- Iterables in Dart Programming
- Lists in Dart Programming
- Loops in Dart Programming
- Maps in Dart Programming
- Methods in Dart Programming
- Mixins in Dart Programming
- Queue in Dart Programming
- Set in Dart Programming
- String in Dart Programming
