mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-09 21:20:17 +00:00
count characters using u8_length instead of size
This commit is contained in:
parent
db9d6349b1
commit
6a540fdbb3
@ -734,7 +734,7 @@ void init_builtins(VM* _vm) {
|
||||
int delta = width - self.u8_length();
|
||||
if(delta <= 0) return args[0];
|
||||
const Str& fillchar = CAST(Str&, args[2]);
|
||||
if (fillchar.size != 1) vm->TypeError("The fill character must be exactly one character long");
|
||||
if (fillchar.u8_length() != 1) vm->TypeError("The fill character must be exactly one character long");
|
||||
SStream ss;
|
||||
ss << self;
|
||||
for(int i=0; i<delta; i++) ss << fillchar;
|
||||
@ -748,7 +748,7 @@ void init_builtins(VM* _vm) {
|
||||
int delta = width - self.u8_length();
|
||||
if(delta <= 0) return args[0];
|
||||
const Str& fillchar = CAST(Str&, args[2]);
|
||||
if (fillchar.size != 1) vm->TypeError("The fill character must be exactly one character long");
|
||||
if (fillchar.u8_length() != 1) vm->TypeError("The fill character must be exactly one character long");
|
||||
SStream ss;
|
||||
for(int i=0; i<delta; i++) ss << fillchar;
|
||||
ss << self;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user