Learn Courses My Dashboard

Special characters in html style json

Im using a Norwegian keyboard with some letters like å æ ø that is not in the English keyboard. Is there a command I can run to make the Learning App display these special characters from the data.json file and the data2.json from GitHub file?

I know that in my case (QWERY keyboard) if you press and hold the character on the keyboard you get a pop-up option to select the character that you want.

For example, if I press and hold down the letter a on my keyboard I get these options:
à, á, â, ä, æ, ã, å and ā

I can get them to show up in a json file too.

Hello,
A HTML browser would render Å as Å .
Class JSONEncoder, and JSONDecoder would handle \u{C5} as Å , where C5 is a UTF-8 value in hexadecimal. See: JSONEncoder and JSONDecoder at developer.apple.com
Hope this helps. I did not check out the Learning App.
Zoli

import UIKit

/*
 From:
 =====
 https://developer.apple.com/documentation/foundation/jsonencoder
 https://developer.apple.com/documentation/foundation/jsondecoder
 */

struct GroceryProduct: Codable {
    var name: String
    var points: Int
    var description: String?
}

let pear = GroceryProduct(name: "Pear", points: 250, description: "A ripe pear. \u{C5}")

let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted

let data = try encoder.encode(pear)
print(String(data: data, encoding: .utf8)!)

//------------------------------------

struct GroceryProduct2: Codable {
    var name: String
    var points: Int
    var description: String?
}

let json = """
{
    "name": "Durian \u{C5}",
    "points": 600,
    "description": "A fruit with a distinctive scent."
}
""".data(using: .utf8)!

let decoder = JSONDecoder()
let product = try decoder.decode(GroceryProduct.self, from: json)

print(product.name) // Prints "Durian"

/*
 Prints:
 =======
 {
   "name" : "Pear",
   "points" : 250,
   "description" : "A ripe pear. Å"
 }
 Durian Å
 */