We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent2c8af12 commite4244d6Copy full SHA for e4244d6
vm/src/format.rs
@@ -477,7 +477,17 @@ impl FormatSpec {
477
},
478
Some(FormatType::Number) =>self.format_int_radix(magnitude,10),
479
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'"),
+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
491
Some(FormatType::GeneralFormatUpper) =>{
492
Err("Unknown format code 'G' for object of type 'int'")
493
}