move decode_helpers to std/private (#16209)

This commit is contained in:
flywind
2020-12-03 02:30:55 +08:00
committed by GitHub
parent af984a3db9
commit 139075e965
3 changed files with 5 additions and 7 deletions

View File

@@ -32,7 +32,7 @@
import strutils, os, strtabs, cookies, uri
export uri.encodeUrl, uri.decodeUrl
include includes/decode_helpers
import std/private/decode_helpers
proc addXmlChar(dest: var string, c: char) {.inline.} =
case c

View File

@@ -47,7 +47,7 @@
import std/private/since
import strutils, parseutils, base64
include includes/decode_helpers
import std/private/decode_helpers
type

View File

@@ -1,14 +1,12 @@
# Include file that implements 'decodePercent' and friends. Do not import it!
proc handleHexChar(c: char, x: var int, f: var bool) {.inline.} =
proc handleHexChar*(c: char, x: var int, f: var bool) {.inline.} =
case c
of '0'..'9': x = (x shl 4) or (ord(c) - ord('0'))
of 'a'..'f': x = (x shl 4) or (ord(c) - ord('a') + 10)
of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
else: f = true
proc decodePercent(s: string, i: var int): char =
## Converts `%xx` hexadecimal to the charracter with ordinal number `xx`.
proc decodePercent*(s: openArray[char], i: var int): char =
## Converts `%xx` hexadecimal to the character with ordinal number `xx`.
##
## If `xx` is not a valid hexadecimal value, it is left intact: only the
## leading `%` is returned as-is, and `xx` characters will be processed in the