1 | #!/usr/bin/env python2
|
2 | from __future__ import print_function
|
3 |
|
4 | from mycpp import mylib
|
5 | from mycpp.mylib import log
|
6 |
|
7 | import fastfunc
|
8 |
|
9 | _ = log
|
10 |
|
11 | LOSSY_JSON = 1 << 3
|
12 |
|
13 |
|
14 | def WriteString(s, options, buf):
|
15 | # type: (str, int, mylib.BufWriter) -> None
|
16 | """Write encoded J8 string to buffer.
|
17 |
|
18 | The C++ version is optimized to avoid the intermediate string.
|
19 | """
|
20 | j8_fallback = not (options & LOSSY_JSON)
|
21 | #print('j8_fallback %d' % j8_fallback)
|
22 | buf.write(fastfunc.J8EncodeString(s, j8_fallback))
|
23 |
|
24 |
|
25 | PartIsUtf8 = fastfunc.PartIsUtf8
|
26 |
|
27 | # vim: sw=4
|