summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
* fixes #3333Andreas Rumpf2019-07-061-6/+6
* fixes #8316 (#11673)Andreas Rumpf2019-07-062-7/+40
* fixes #7057Andreas Rumpf2019-07-061-1/+1
* ABI fixes for OSX/BSD; fixes #6860 (#11666)Andreas Rumpf2019-07-069-11/+613
* Documentation Diff, Typo (#11566)Juan Carlos2019-07-061-1/+23
* nimpretty: improved detection of commas and semicolons (#11661)Miran2019-07-063-4/+15
* introduce internal Int128 type, use it to fix case stmt checks (#11652)Arne Döring2019-07-056-11/+550
* nimpretty: don't touch formatted multiline comments (#11663)Miran2019-07-053-23/+87
* Fixes #11662: render ops priority (#11664)cooldome2019-07-052-4/+12
* nimpretty: nicer debugging [ci skip]narimiran2019-07-051-1/+1
* nimpretty: relax line length rules when dealing with (inline) comments (#11657)Miran2019-07-054-10/+36
* fix #11651 exportc symbol not exported, leading to link error (#11658)Timothee Cour2019-07-051-3/+2
* fixes #11610 (#11659)Andreas Rumpf2019-07-054-7/+22
* manual: document block expression (#11638)Tomohiro2019-07-051-0/+15
* newruntime for async (#11650)Andreas Rumpf2019-07-0512-47/+60
* Make public some sha1 module procedures (#11655) [feature]Ivan Bobev2019-07-041-3/+3
* Corrected example shown in documentation (#11654) [ci skip]Akito132019-07-041-1/+1
* Fix the broken link in math.nim (#11653) [ci skip]Graeme Cross2019-07-041-1/+1
* nimpretty: fix out of bounds error [ci skip]narimiran2019-07-041-2/+3
* nimpretty: nimpretty now understands splitting newlinesAraq2019-07-042-8/+34
* nimpretty: distinguish between the different kinds of newlines in NimAraq2019-07-041-10/+16
* fixes #8405: -d:useNimRtl now works even when {.rtl.} procs are used at compi...Timothee Cour2019-07-035-61/+68
* [bugfix] fix wrong nimpretty unidents, refs #11616 (#11645)Miran2019-07-033-1/+26
* fixes #11585Andreas Rumpf2019-07-031-2/+3
* [bugfix] fix mach_absolute_time header; refs #11591 (#11593)Timothee Cour2019-07-031-2/+2
* [bugfix] fix #11484, acknowledge 'danger' flag (#11486)Miran2019-07-031-1/+2
* fixes #11510Araq2019-07-032-3/+25
* fixes #11636Araq2019-07-031-2/+5
* Added 'keys' iterator to JsonNode (#11597) [feature]Liam Sc2019-07-031-0/+6
* [backport] fix #11320 (#11538)Arne Döring2019-07-034-6/+17
* Implement some custom formatting for input fields in the documentation (#11632)Hugo Locurcio2019-07-036-0/+102
* Documentation improvements to the times module (#11639)Graeme Cross2019-07-031-27/+27
* fixes #11479 (#11641)Andreas Rumpf2019-07-032-1/+20
* [bugfix] nimpretty indents multiline comments correctly (#11607)Miran2019-07-023-0/+42
* fixes #11633Andreas Rumpf2019-07-011-1/+1
* fixes #11515 (#11624)Andreas Rumpf2019-07-014-6/+8
* fixes #11618 (#11631)Andreas Rumpf2019-07-012-1/+3
* assertions: fixes #11545 (#11605)alaviss2019-07-015-7/+22
* fixes #11617Araq2019-07-011-0/+3
* fixes #11628Araq2019-07-011-0/+1
* fixes #11614Araq2019-07-012-1/+13
* Make repr use 'ptr' for ptr types instead of 'ref' (#11626)Ico Doornekamp2019-07-011-1/+2
* Remove IO.js compat (long dead vanished project,superseed by NodeJS) (#11627)Juan Carlos2019-07-011-4/+2
* [bugfix] make -d:nimSetUtf8CodePage switch work againAraq2019-07-011-1/+1
* added destructors.rst documentAndreas Rumpf2019-07-011-0/+563
* msgs, ccgstmts: fixes #11572 (#11621)alaviss2019-06-302-8/+15
* [other] additions to the manualAndreas Rumpf2019-06-291-1/+76
* fixes #11606Araq2019-06-281-2/+8
* fixes #11611Araq2019-06-282-2/+2
* Pass additional koch options to the nim compiler (#11615)Ivan Bobev2019-06-281-36/+44
first: delta div Damp else: delta div 2 d += d div numPoints var k = 0 while d > ((Base-TMin)*TMax) div 2: d = d div (Base - TMin) k += Base result = k + (Base - TMin + 1) * d div (d + Skew) proc encode*(prefix, s: string): string {.raises: [PunyError].} = ## Encode a string that may contain Unicode. ## Prepend `prefix` to the result result = prefix var (d, n, bias) = (0, InitialN, InitialBias) var (b, remaining) = (0, 0) for r in s.runes: if r.isBasic: # basic Ascii character inc b result.add($r) else: # special character inc remaining var h = b if b > 0: result.add(Delimiter) # we have some Ascii chars while remaining != 0: var m: int = high(int32) for r in s.runes: if m > int(r) and int(r) >= n: m = int(r) d += (m - n) * (h + 1) if d < 0: raise newException(PunyError, "invalid label " & s) n = m for r in s.runes: if int(r) < n: inc d if d < 0: raise newException(PunyError, "invalid label " & s) continue if int(r) > n: continue var q = d var k = Base while true: var t = k - bias if t < TMin: t = TMin elif t > TMax: t = TMax if q < t: break result.add($encodeDigit(t + (q - t) mod (Base - t))) q = (q - t) div (Base - t) k += Base result.add($encodeDigit(q)) bias = adapt(d, h + 1, h == b) d = 0 inc h dec remaining inc d inc n proc encode*(s: string): string {.raises: [PunyError].} = ## Encode a string that may contain Unicode. Prefix is empty. result = encode("", s) proc decode*(encoded: string): string {.raises: [PunyError].} = ## Decode a Punycode-encoded string var n = InitialN i = 0 bias = InitialBias var d = rfind(encoded, Delimiter) result = "" if d > 0: # found Delimiter for j in 0..<d: var c = encoded[j] # char if not c.isBasic: raise newException(PunyError, "Encoded contains a non-basic char") result.add(c) # add the character inc d else: d = 0 # set to first index while (d < len(encoded)): var oldi = i var w = 1 var k = Base while true: if d == len(encoded): raise newException(PunyError, "Bad input: " & encoded) var c = encoded[d]; inc d var digit = int(decodeDigit(c)) if digit > (high(int32) - i) div w: raise newException(PunyError, "Too large a value: " & $digit) i += digit * w var t: int if k <= bias: t = TMin elif k >= bias + TMax: t = TMax else: t = k - bias if digit < t: break w *= Base - t k += Base bias = adapt(i - oldi, runelen(result) + 1, oldi == 0) if i div (runelen(result) + 1) > high(int32) - n: raise newException(PunyError, "Value too large") n += i div (runelen(result) + 1) i = i mod (runelen(result) + 1) insert(result, $Rune(n), i) inc i when isMainModule: assert(decode(encode("", "bücher")) == "bücher") assert(decode(encode("münchen")) == "münchen") assert encode("xn--", "münchen") == "xn--mnchen-3ya"