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,7 +167,11 @@ public class TextModuleWriter extends ModuleWriter {
textOutput.append( "(data (i32.const 0) \"" );
byte[] data = dataStream.toByteArray();
for( byte b : data ) {
textOutput.append( '\\' ).append( Character.forDigit( (b >> 4) & 0xF, 16 ) ).append( Character.forDigit( b & 0xF, 16 ) );
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( "\")" );
}