I have a need to read various files, and convert some of the words to a specific case (which can’t be done using normal functions like upper, lower or title)
Right now I have a rather large method that inserts keys into an SQLite database
The app the ultimatly needs to deal with these files is very strict on case
CREATE TABLE translate (
KEY Text COLLATE NOCASE UNIQUE DEFAULT '',
newVALUE Text COLLATE NOCASE DEFAULT '')
this is done with 3 different methods
private func addKey_UPPER(_ newValue: String) {
let key=newValue.uppercased()
storeAs(key,newValue)
}
private func addKey_DELETE(_ newValue: String) {
let key=newValue.uppercased()
storeAs(key,"*")
}
private func addKey_REPLACE(_ key : String, _ newValue: String) {
storeAs(key.uppercased(),newValue)
}
private func storeAs(_ key:String,_ newValue:String) {
let _ = DB.SQLExecute("INSERT INTO \(translateTABLE) (key,newValue) VALUES('\(key)','\(newValue)')")
}
at the appropriate time a word is looked up in that table by KEY and replaced by its “NEWVALUE”. or removed if newvalue="*"
anyone have an idea how to create this table with cleaner code?
right now there are 559 “words” in this table, and I expect the need to increase