For more reading on testing, check out Unit Tests Don't Prevent Bugs .
For more reading on testing, check out Unit Tests Don't Prevent Bugs .
Of course, that particular map just covers the characters that might map to "e"
, and we'd have to do this before we applied the ASCII rule. But applicationimplementation would look something like this:
Of course, that particular map just covers the characters that might map to "e"
, and we'd have to do this before we applied the ASCII rule. But application would look something like this:
Of course, that particular map just covers the characters that might map to "e"
, and we'd have to do this before we applied the ASCII rule. But implementation would look something like this:
As an addendum, one thing that might be neat to add to the StringFormatter
struct would be a means for mapping certain characters to be replaced with specified characters. So, for example, you're not going to allow ASCII, but you could potentially replace è
with a "regular" e
.
So we might add a property to the struct that looks like this:
var replacementMap = [Character: Character]()
So it's a dictionary where the key is the character we want to remove and the value is the character we want to replace it with.
stringFormatter.replacementMap = [
"è" : "e",
"é" : "e",
"ê" : "e",
"ë" : "e",
"ē" : "e",
"ė" : "e",
"ę" : "e"
]
Of course, that particular map just covers the characters that might map to "e"
, and we'd have to do this before we applied the ASCII rule. But application would look something like this:
private func stringByApplyingReplacementMap(string: String) -> String {
return String(string.characters.map { return self.replacementMap[0ドル] ?? 0ドル })
}
As an addendum, one thing that might be neat to add to the StringFormatter
struct would be a means for mapping certain characters to be replaced with specified characters. So, for example, you're not going to allow ASCII, but you could potentially replace è
with a "regular" e
.
So we might add a property to the struct that looks like this:
var replacementMap = [Character: Character]()
So it's a dictionary where the key is the character we want to remove and the value is the character we want to replace it with.
stringFormatter.replacementMap = [
"è" : "e",
"é" : "e",
"ê" : "e",
"ë" : "e",
"ē" : "e",
"ė" : "e",
"ę" : "e"
]
Of course, that particular map just covers the characters that might map to "e"
, and we'd have to do this before we applied the ASCII rule. But application would look something like this:
private func stringByApplyingReplacementMap(string: String) -> String {
return String(string.characters.map { return self.replacementMap[0ドル] ?? 0ドル })
}