mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-13 06:43:52 +00:00
lib: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
This commit is contained in:
@@ -7,19 +7,19 @@
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module is based on Python's Unidecode module by Tomaz Solc,
|
||||
## which in turn is based on the ``Text::Unidecode`` Perl module by
|
||||
## Sean M. Burke
|
||||
## This module is based on Python's Unidecode module by Tomaz Solc,
|
||||
## which in turn is based on the ``Text::Unidecode`` Perl module by
|
||||
## Sean M. Burke
|
||||
## (http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm ).
|
||||
##
|
||||
## It provides a single proc that does Unicode to ASCII transliterations:
|
||||
## It finds the sequence of ASCII characters that is the closest approximation
|
||||
## to the Unicode string.
|
||||
##
|
||||
## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some
|
||||
## information is lost in this transformation, of course, since several Unicode
|
||||
## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some
|
||||
## information is lost in this transformation, of course, since several Unicode
|
||||
## strings can be transformed in the same ASCII representation. So this is a
|
||||
## strictly one-way transformation. However a human reader will probably
|
||||
## strictly one-way transformation. However a human reader will probably
|
||||
## still be able to guess what original string was meant from the context.
|
||||
##
|
||||
## This module needs the data file "unidecode.dat" to work: You can either
|
||||
@@ -31,7 +31,7 @@ import unicode
|
||||
|
||||
when defined(embedUnidecodeTable):
|
||||
import strutils
|
||||
|
||||
|
||||
const translationTable = splitLines(slurp"unidecode/unidecode.dat")
|
||||
else:
|
||||
# shared is fine for threading:
|
||||
@@ -49,12 +49,12 @@ proc loadUnidecodeTable*(datafile = "unidecode.dat") =
|
||||
translationTable[i] = line.string
|
||||
inc(i)
|
||||
|
||||
proc unidecode*(s: string): string =
|
||||
proc unidecode*(s: string): string =
|
||||
## Finds the sequence of ASCII characters that is the closest approximation
|
||||
## to the UTF-8 string `s`.
|
||||
##
|
||||
## Example:
|
||||
##
|
||||
## Example:
|
||||
##
|
||||
## ..code-block:: nim
|
||||
##
|
||||
## unidecode("\x53\x17\x4E\xB0")
|
||||
@@ -63,7 +63,7 @@ proc unidecode*(s: string): string =
|
||||
##
|
||||
assert(not isNil(translationTable))
|
||||
result = ""
|
||||
for r in runes(s):
|
||||
for r in runes(s):
|
||||
var c = int(r)
|
||||
if c <=% 127: add(result, chr(c))
|
||||
elif c <% translationTable.len: add(result, translationTable[c-128])
|
||||
|
||||
Reference in New Issue
Block a user