diff --git a/binary/decoder_test.js b/binary/decoder_test.js index b8e1084..7a71c0d 100644 --- a/binary/decoder_test.js +++ b/binary/decoder_test.js @@ -375,11 +375,11 @@ describe('binaryDecoderTest', () => { const decoder = jspb.BinaryDecoder.alloc(encoder.end()); - expect(decoder.readString(ascii.length, true)).toEqual(ascii); - expect(utf8_two_bytes).toEqual(decoder.readString(2, true)); + expect(decoder.readString(ascii.length, /* enforceUtf8= */ true)).toEqual(ascii); + expect(utf8_two_bytes).toEqual(decoder.readString(2, /* enforceUtf8= */ true)); expect(utf8_three_bytes) - .toEqual(decoder.readString(3, true)); - expect(utf8_four_bytes).toEqual(decoder.readString(4, true)); + .toEqual(decoder.readString(3, /* enforceUtf8= */ true)); + expect(utf8_four_bytes).toEqual(decoder.readString(4, /* enforceUtf8= */ true)); }); /** diff --git a/generator/js_generator.cc b/generator/js_generator.cc index 8136f58..6ca0ad3 100644 --- a/generator/js_generator.cc +++ b/generator/js_generator.cc @@ -1079,7 +1079,7 @@ std::string JSBinaryMethodType(const FieldDescriptor* field, bool is_writer) { name[0] = (name[0] - 'a') + 'A'; } if (!is_writer && field->type() == FieldDescriptor::TYPE_STRING && - field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { + field->requires_utf8_validation()) { name = name + "RequireUtf8"; } return IsIntegralFieldWithStringJSType(field) ? (name + "String") : name;