Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4244d6

Browse files
committed
Fix character format
1 parent2c8af12 commite4244d6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎vm/src/format.rs‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,17 @@ impl FormatSpec {
477477
},
478478
Some(FormatType::Number) =>self.format_int_radix(magnitude,10),
479479
Some(FormatType::String) =>Err("Unknown format code 's' for object of type 'int'"),
480-
Some(FormatType::Character) =>Err("Unknown format code 'c' for object of type 'int'"),
480+
Some(FormatType::Character) =>match(self.sign,self.alternate_form){
481+
(Some(_), _) =>Err("Sign not allowed with integer format specifier 'c'"),
482+
(_,true) =>{
483+
Err("Alternate form (#) not allowed with integer format specifier 'c'")
484+
}
485+
(_, _) =>match num.to_u32(){
486+
Some(n)if n <=0x10ffff =>Ok(std::char::from_u32(n).unwrap().to_string()),
487+
// TODO: raise OverflowError
488+
Some(_) |None =>Err("%c arg not in range(0x110000)"),
489+
},
490+
},
481491
Some(FormatType::GeneralFormatUpper) =>{
482492
Err("Unknown format code 'G' for object of type 'int'")
483493
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp