How to resolve the algorithm Character codes step by step in the Wren programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Character codes step by step in the Wren programming language
Table of Contents
Problem Statement
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode). Conversely, given a code, print out the corresponding character.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Character codes step by step in the Wren programming language
Source code in the wren programming language
var cps = []
for (c in ["a", "π", "字", "🐘"]) {
var cp = c.codePoints[0]
cps.add(cp)
System.print("%(c) = %(cp)")
}
System.print()
for (i in cps) {
var c = String.fromCodePoint(i)
System.print("%(i) = %(c)")
}
You may also check:How to resolve the algorithm Guess the number step by step in the Racket programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Babel programming language
You may also check:How to resolve the algorithm Magic constant step by step in the Prolog programming language
You may also check:How to resolve the algorithm Sequence: nth number with exactly n divisors step by step in the Ruby programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the REXX programming language