Skip to content

Commit ff84a31

Browse files
DuffsDeviceJakob Riedle
andauthored
JR: Fixed #57
Co-authored-by: Jakob Riedle <[email protected]>
1 parent 295c6a5 commit ff84a31

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

include/tinyutf8/tinyutf8.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,6 @@ namespace tiny_utf8
643643
data{ value , '\0' }
644644
, data_len( (unsigned char)( size - 1u ) << 1 )
645645
{}
646-
SSO( size_type data_len ) noexcept :
647-
// Note: No initialization of .data (important for the constructor of basic_string(value_type)...)
648-
data_len( (unsigned char)( ( size - data_len ) << 1 ) )
649-
{
650-
data[data_len] = '\0'; // Add delimiter to actual data
651-
}
652646
SSO() noexcept :
653647
data{ '\0' }
654648
, data_len( (unsigned char)( size - 0 ) << 1 )
@@ -1246,8 +1240,10 @@ namespace tiny_utf8
12461240
explicit inline basic_string( value_type cp , const allocator_type& alloc = allocator_type() )
12471241
noexcept(TINY_UTF8_NOEXCEPT)
12481242
: Allocator( alloc )
1249-
, t_sso( (size_type)encode_utf8( cp , t_sso.data ) )
1250-
{}
1243+
{
1244+
t_sso.data[ cp = encode_utf8( cp , t_sso.data ) ] = '\0';
1245+
set_sso_data_len( cp );
1246+
}
12511247
/**
12521248
* Constructor that fills the string with the supplied character
12531249
*

0 commit comments

Comments
 (0)