AsPrintableString parses a ASN.1 PrintableString from the given byte array and returns it.
()
| 277 | // AsPrintableString parses a ASN.1 PrintableString from the given byte |
| 278 | // array and returns it. |
| 279 | func (v *Token) AsPrintableString() (ret string, err error) { |
| 280 | v.mustBeValue() |
| 281 | bytes := v.Bytes |
| 282 | for _, b := range bytes { |
| 283 | if !isPrintable(b) { |
| 284 | err = SyntaxError{"PrintableString contains invalid character"} |
| 285 | return |
| 286 | } |
| 287 | } |
| 288 | ret = string(bytes) |
| 289 | return |
| 290 | } |
| 291 | |
| 292 | // isPrintable returns true iff the given b is in the ASN.1 PrintableString set. |
| 293 | func isPrintable(b byte) bool { |
no test coverage detected