Code chars in data section directly and not escaped

This commit is contained in:
Volker Berlin 2019-12-23 21:28:26 +01:00
parent 371cde8c0e
commit 7bd7e82063

View File

@ -167,8 +167,12 @@ public class TextModuleWriter extends ModuleWriter {
textOutput.append( "(data (i32.const 0) \"" ); textOutput.append( "(data (i32.const 0) \"" );
byte[] data = dataStream.toByteArray(); byte[] data = dataStream.toByteArray();
for( byte b : data ) { for( byte b : data ) {
if( b >= ' ' && b < 0x7F && b != '\"' && b != '\\' ) {
textOutput.append( (char)b );
} else {
textOutput.append( '\\' ).append( Character.forDigit( (b >> 4) & 0xF, 16 ) ).append( Character.forDigit( b & 0xF, 16 ) ); textOutput.append( '\\' ).append( Character.forDigit( (b >> 4) & 0xF, 16 ) ).append( Character.forDigit( b & 0xF, 16 ) );
} }
}
textOutput.append( "\")" ); textOutput.append( "\")" );
} }