// Copyright (C) 2022-2023 Luke Shumaker // // SPDX-License-Identifier: GPL-2.0-or-later package lowmemjson import ( "git.lukeshu.com/go/lowmemjson/internal/jsonparse" ) type reEncodeString struct { out reEncoderModule // BackslashEscape returns whether a given character in a // string should be backslash-escaped. The bool argument is // whether it was \u-escaped in the input. This does not // affect characters that must or must-not be escaped to be // valid JSON. BackslashEscape BackslashEscaper } var _ reEncoderModule = (*reEncodeString)(nil) func (enc *reEncodeString) PopWriteBarrier() { enc.out.PopWriteBarrier() } func (enc *reEncodeString) HandleRune(c rune, t jsonparse.RuneType, escape BackslashEscapeMode, stackSize int) error { if t == jsonparse.RuneTypeStringChar { escape = enc.BackslashEscape(c, escape) } return enc.out.HandleRune(c, t, escape, stackSize) }