1// Copyright 2015 Garrett D'Amore 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use file except in compliance with the License. 5// You may obtain a copy of the license at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package encoding 16 17import ( 18 "golang.org/x/text/encoding" 19) 20 21// ASCII represents the 7-bit US-ASCII scheme. It decodes directly to 22// UTF-8 without change, as all ASCII values are legal UTF-8. 23// Unicode values less than 128 (i.e. 7 bits) map 1:1 with ASCII. 24// It encodes runes outside of that to 0x1A, the ASCII substitution character. 25var ASCII encoding.Encoding 26 27func init() { 28 amap := make(map[byte]rune) 29 for i := 128; i <= 255; i++ { 30 amap[byte(i)] = RuneError 31 } 32 33 cm := &Charmap{Map: amap} 34 cm.Init() 35 ASCII = cm 36} 37