equal
deleted
inserted
replaced
37 _jsonescapeu8fast = charencode.jsonescapeu8fast |
37 _jsonescapeu8fast = charencode.jsonescapeu8fast |
38 |
38 |
39 _sysstr = pycompat.sysstr |
39 _sysstr = pycompat.sysstr |
40 |
40 |
41 unichr = chr |
41 unichr = chr |
|
42 |
|
43 if typing.TYPE_CHECKING: |
|
44 # TODO: make a stub file for .cext.charencode, and import here |
|
45 from .pure.charencode import ( |
|
46 asciilower, |
|
47 asciiupper, |
|
48 isasciistr, |
|
49 jsonescapeu8fast as _jsonescapeu8fast, |
|
50 ) |
|
51 |
42 |
52 |
43 # These unicode characters are ignored by HFS+ (Apple Technote 1150, |
53 # These unicode characters are ignored by HFS+ (Apple Technote 1150, |
44 # "Unicode Subtleties"), so we need to ignore them in some places for |
54 # "Unicode Subtleties"), so we need to ignore them in some places for |
45 # sanity. |
55 # sanity. |
46 _ignore = [ |
56 _ignore = [ |
522 lower = -1 |
532 lower = -1 |
523 upper = 1 |
533 upper = 1 |
524 other = 0 |
534 other = 0 |
525 |
535 |
526 |
536 |
527 def jsonescape(s: Any, paranoid: Any = False) -> Any: |
537 def jsonescape(s: bytes, paranoid: bool = False) -> bytes: |
528 """returns a string suitable for JSON |
538 """returns a string suitable for JSON |
529 |
539 |
530 JSON is problematic for us because it doesn't support non-Unicode |
540 JSON is problematic for us because it doesn't support non-Unicode |
531 bytes. To deal with this, we take the following approach: |
541 bytes. To deal with this, we take the following approach: |
532 |
542 |