Skip to content

Commit

Permalink
Merge pull request #33 from buttercrab/dev
Browse files Browse the repository at this point in the history
fixed #32 unicode error
  • Loading branch information
buttercrab authored Mar 23, 2020
2 parents 2c7ae41 + f16ff94 commit 9323130
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyeong"
version = "0.1.1"
version = "0.1.2"
authors = ["buttercrab <jaeyong0201@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
More explanation on [Documentation](https://github.com/buttercrab/hyeo-ung-lang/wiki/Documentation).

```
hyeong 0.1.1
hyeong 0.1.2
hyeo-ung programming language tool
USAGE:
Expand Down
4 changes: 2 additions & 2 deletions src/core/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ impl Stack {
fn push(&mut self, idx: usize, num: Num) {
if idx == 1 {
if num.is_pos() {
print!(\"{}\", num.floor().to_int() as u8 as char);
print!(\"{}\", std::char::from_u32(num.floor().to_int()).unwrap());
} else {
print!(\"{}\", -&num);
}
return;
}
if idx == 2 {
if num.is_pos() {
eprint!(\"{}\", num.floor().to_int() as u8 as char);
eprint!(\"{}\", std::char::from_u32(num.floor().to_int()).unwrap());
} else {
eprint!(\"{}\", -&num);
}
Expand Down
20 changes: 18 additions & 2 deletions src/core/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,30 @@ where
match idx {
1 => {
if num.is_pos() {
write!(out, "{}", num.floor().to_int() as u8 as char)?;
let n = num.floor().to_int();
write!(
out,
"{}",
std::char::from_u32(n).ok_or(Error::new(
"utf-8 encoding error",
format!("number {} was not valid unicode", n)
))?
)?;
} else {
write!(out, "{}", -&num)?;
}
}
2 => {
if num.is_pos() {
write!(err, "{}", num.floor().to_int() as u8 as char)?;
let n = num.floor().to_int();
write!(
err,
"{}",
std::char::from_u32(n).ok_or(Error::new(
"utf-8 encoding error",
format!("number {} was not valid unicode", n)
))?
)?;
} else {
write!(err, "{}", -&num)?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn sub_main(
/// Main function of this program
///
/// ```text
/// hyeong 0.1.1
/// hyeong 0.1.2
/// hyeo-ung programming language tool
///
/// USAGE:
Expand All @@ -127,7 +127,7 @@ fn sub_main(
#[cfg(not(feature = "number"))]
fn main() {
let matches = App::new("hyeong")
.version("0.1.1")
.version("0.1.2")
.about("hyeo-ung programming language tool")
.arg(option::color())
.subcommand(build::app())
Expand Down

0 comments on commit 9323130

Please sign in to comment.