blob: e56a0dd43eda15231813163ea2946c2311049e33 [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// 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
7package stringprep
8
9// Mapping represents a stringprep mapping, from a single rune to zero or more
10// runes.
11type 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.
15func (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}