diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-06 13:52:20 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-06 13:52:20 -0800 |
| commit | c0068f11c51bb587c16dfacb73629b3c6fb67fc8 (patch) | |
| tree | 20753433f348b03bb590e0fe6a4cafbe56f4c859 /Hotline/Utility | |
| parent | 06a2166415bca7e5fe32eac505859bdd690ab8e0 (diff) | |
Further work on UI organization
Diffstat (limited to 'Hotline/Utility')
| -rw-r--r-- | Hotline/Utility/DataExtensions.swift | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Hotline/Utility/DataExtensions.swift b/Hotline/Utility/DataExtensions.swift index 9f4c967..aefd204 100644 --- a/Hotline/Utility/DataExtensions.swift +++ b/Hotline/Utility/DataExtensions.swift @@ -51,8 +51,15 @@ extension Data { return self.subdata(in: offset..<(offset + length)) } - func readString(at offset: Int, length: Int, encoding: String.Encoding) -> String? { - return String(data: self[offset..<(offset + length)], encoding: encoding) + func readString(at offset: Int, length: Int) -> String? { + var str: String? + + str = String(data: self[offset..<(offset + length)], encoding: .utf8) + if str == nil { + str = String(data: self[offset..<(offset + length)], encoding: .ascii) + } + + return str } |