Don Newton | 379ae25 | 2019-04-01 12:17:06 -0400 | [diff] [blame^] | 1 | // Copyright 2018 by David A. Golden. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | // not use this file except in compliance with the License. You may obtain |
| 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | |
| 7 | package stringprep |
| 8 | |
| 9 | // Mapping represents a stringprep mapping, from a single rune to zero or more |
| 10 | // runes. |
| 11 | type Mapping map[rune][]rune |
| 12 | |
| 13 | // Map maps a rune to a (possibly empty) rune slice via a stringprep Mapping. |
| 14 | // The ok return value is false if the rune was not found. |
| 15 | func (m Mapping) Map(r rune) (replacement []rune, ok bool) { |
| 16 | rs, ok := m[r] |
| 17 | if !ok { |
| 18 | return nil, false |
| 19 | } |
| 20 | return rs, true |
| 21 | } |