@@ -421,31 +421,31 @@ def store_string_into_range(opts, v):
421
421
match opts .string_encoding :
422
422
case 'utf8' :
423
423
match src_simple_encoding :
424
- case 'utf8' : return store_string_copy (opts , src , src_code_units , 1 , 'utf-8' )
424
+ case 'utf8' : return store_string_copy (opts , src , src_code_units , 1 , 1 , 'utf-8' )
425
425
case 'utf16' : return store_utf16_to_utf8 (opts , src , src_code_units )
426
426
case 'latin1' : return store_latin1_to_utf8 (opts , src , src_code_units )
427
427
case 'utf16' :
428
428
match src_simple_encoding :
429
429
case 'utf8' : return store_utf8_to_utf16 (opts , src , src_code_units )
430
- case 'utf16' : return store_string_copy (opts , src , src_code_units , 2 , 'utf-16-le' )
431
- case 'latin1' : return store_string_copy (opts , src , src_code_units , 2 , 'utf-16-le' )
430
+ case 'utf16' : return store_string_copy (opts , src , src_code_units , 2 , 2 , 'utf-16-le' )
431
+ case 'latin1' : return store_string_copy (opts , src , src_code_units , 2 , 2 , 'utf-16-le' )
432
432
case 'latin1+utf16' :
433
433
match src_encoding :
434
434
case 'utf8' : return store_string_to_latin1_or_utf16 (opts , src , src_code_units )
435
435
case 'utf16' : return store_string_to_latin1_or_utf16 (opts , src , src_code_units )
436
436
case 'latin1+utf16' :
437
437
match src_simple_encoding :
438
- case 'latin1' : return store_string_copy (opts , src , src_code_units , 1 , 'latin-1' )
438
+ case 'latin1' : return store_string_copy (opts , src , src_code_units , 1 , 2 , 'latin-1' )
439
439
case 'utf16' : return store_probably_utf16_to_latin1_or_utf16 (opts , src , src_code_units )
440
440
441
441
#
442
442
443
443
MAX_STRING_BYTE_LENGTH = (1 << 31 ) - 1
444
444
445
- def store_string_copy (opts , src , src_code_units , dst_code_unit_size , dst_encoding ):
445
+ def store_string_copy (opts , src , src_code_units , dst_code_unit_size , dst_alignment , dst_encoding ):
446
446
dst_byte_length = dst_code_unit_size * src_code_units
447
447
trap_if (dst_byte_length > MAX_STRING_BYTE_LENGTH )
448
- ptr = opts .realloc (0 , 0 , dst_code_unit_size , dst_byte_length )
448
+ ptr = opts .realloc (0 , 0 , dst_alignment , dst_byte_length )
449
449
encoded = src .encode (dst_encoding )
450
450
assert (dst_byte_length == len (encoded ))
451
451
opts .memory [ptr : ptr + len (encoded )] = encoded
0 commit comments