github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/core/symbols.go (about) 1 /* 2 * This file is subject to the terms and conditions defined in 3 * file 'LICENSE.md', which is part of this source code package. 4 */ 5 6 package core 7 8 // IsWhiteSpace checks if byte represents a white space character. 9 // TODO (v3): Unexport. 10 func IsWhiteSpace(ch byte) bool { 11 // Table 1 white-space characters (7.2.2 Character Set) 12 // spaceCharacters := string([]byte{0x00, 0x09, 0x0A, 0x0C, 0x0D, 0x20}) 13 if (ch == 0x00) || (ch == 0x09) || (ch == 0x0A) || (ch == 0x0C) || (ch == 0x0D) || (ch == 0x20) { 14 return true 15 } 16 return false 17 } 18 19 // IsFloatDigit checks if a character can be a part of a float number string. 20 // TODO (v3): Unexport. 21 func IsFloatDigit(c byte) bool { 22 return ('0' <= c && c <= '9') || c == '.' 23 } 24 25 // IsDecimalDigit checks if the character is a part of a decimal number string. 26 // TODO (v3): Unexport. 27 func IsDecimalDigit(c byte) bool { 28 if c >= '0' && c <= '9' { 29 return true 30 } else { 31 return false 32 } 33 } 34 35 // IsOctalDigit checks if a character can be part of an octal digit string. 36 // TODO (v3): Unexport. 37 func IsOctalDigit(c byte) bool { 38 if c >= '0' && c <= '7' { 39 return true 40 } else { 41 return false 42 } 43 } 44 45 // IsPrintable checks if a character is printable. 46 // Regular characters that are outside the range EXCLAMATION MARK(21h) 47 // (!) to TILDE (7Eh) (~) should be written using the hexadecimal notation. 48 // TODO (v3): Unexport. 49 func IsPrintable(char byte) bool { 50 if char < 0x21 || char > 0x7E { 51 return false 52 } 53 return true 54 } 55 56 // IsDelimiter checks if a character represents a delimiter. 57 // TODO (v3): Unexport. 58 func IsDelimiter(char byte) bool { 59 if char == '(' || char == ')' { 60 return true 61 } 62 if char == '<' || char == '>' { 63 return true 64 } 65 if char == '[' || char == ']' { 66 return true 67 } 68 if char == '{' || char == '}' { 69 return true 70 } 71 if char == '/' { 72 return true 73 } 74 if char == '%' { 75 return true 76 } 77 78 return false 79 }