我有这个Base64解码代码 -
--
(NSString *)DecodeBase64:(NSString *)Value; {
//Return the decoded Base64 string. string must be multiple of 4 chars in length
NSUInteger paddedLength = Value.length + (4 - (Value.length % 4));
NSString *paddedBase64 = [Value stringByPaddingToLength:paddedLength withString:@"=" startingAtIndex:0];
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:paddedBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];
return decodedString;
}
--
解码此字符串 -
PD94bWwgdmVyc21vbj0iMS4wIiBlbmNvVGluZz0i
返回此字符串 -
<?xml versmon="1.0" encoTing="
出现错误,拼写错误的“版本”和“编码” - 2个不正确的字符。
源字符串来自一个非常大的政府机构,所以我不认为这是不正确的......
代码有问题吗?