added empty string case

This commit is contained in:
Haik Aslanyan
2020-04-10 20:36:28 +04:00
parent f5bbea8449
commit 8536388420
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -41,6 +41,9 @@ extension RCBitCoder {
guard message.count <= configuration.maxMessageCount else {
throw RCError.longText
}
guard !message.isEmpty else {
return [RCBit](repeating: .zero, count: configuration.version.maxBitesPerSection * 4)
}
//mapping into character indexes
var indexes = message.map({configuration.characters.firstIndex(of: $0)!})
//adding staring character index and filling with special indexes
+1 -1
View File
@@ -38,7 +38,7 @@ public extension RCCoder {
func encode(_ image: RCImage) throws -> UIImage {
let bits = try bitCoder.encode(message: image.message)
let image = imageEncoder.encode(image, bits: bits)
return UIImage()
return image
}
func decode(_ image: UIImage) throws -> String {