[READ-ONLY] Mirror of https://github.com/probablykasper/cpc. Text calculator with support for units and conversion cpc.kasper.space
calculator cli conversion converter library math package units units-converter wasm website
0

Configure Feed

Select the types of activity you want to include in your feed.

Add `deg`, `degrees` ambiguous unit

Kasper (Jul 1, 2026, 9:07 AM +0200) c1a33b2b 7af70f17

+23 -5
+1 -1
CHANGELOG.md
··· 2 2 3 3 ## Next 4 4 - Add ambiguous unit resolution depending on context and user locale. 5 - - Add ambiguous units like `pound` 5 + - Add ambiguous units like `pound`, `deg`, `$` and `kr` 6 6 - Add currency symbols like `€` and `kr` 7 7 - Add `as` and `into` keywords for unit conversion 8 8 - Fix some units not being simplified
+22 -4
src/lexer.rs
··· 22 22 "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" 23 23 | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" => true, 24 24 "Ω" | "Ω" | "µ" | "μ" | "ł" | "$" | "€" | "£" | "₹" | "₪" | "¥" | "₩" | "₱" | "฿" | "₺" 25 - | "₴" | "₫" | "đ" | "Đ" | "č" => true, 25 + | "₴" | "₫" | "đ" | "Đ" | "č" | "°" => true, 26 26 _ => false, 27 27 } 28 28 } ··· 643 643 "fps" => Token::unit(FeetPerSecond), 644 644 "kn" | "kt" | "knot" | "knots" => Token::unit(Knot), 645 645 646 - "k" | "kelvin" | "kelvins" => Token::unit(Kelvin), 647 - "c" | "celsius" => Token::unit(Celsius), 648 - "f" | "fahrenheit" | "fahrenheits" => Token::unit(Fahrenheit), 646 + "°" | "deg" | "degs" | "degree" | "degrees" => match read_word(lexer).as_str() { 647 + "k" | "kelvin" | "kelvins" => Token::unit(Kelvin), 648 + "c" | "celsius" | "celcius" => Token::unit(Celsius), 649 + "f" | "fahrenheit" | "fahrenheits" | "farenheit" | "farenheits" => { 650 + Token::unit(Fahrenheit) 651 + } 652 + other => { 653 + let token = match get_region().as_str() { 654 + "BS" | "BZ" | "KY" | "PR" | "PW" | "US" => Fahrenheit, 655 + _ => Celsius, 656 + }; 657 + lexer.tokens.push(Token::unit(token)); 658 + lex_word_if_non_empty(other, lexer)?; 659 + return Ok(()); 660 + } 661 + }, 662 + "k" | "°k" | "kelvin" | "kelvins" => Token::unit(Kelvin), 663 + "c" | "°c" | "celsius" | "celcius" => Token::unit(Celsius), 664 + "f" | "°f" | "fahrenheit" | "fahrenheits" | "farenheit" | "farenheits" => { 665 + Token::unit(Fahrenheit) 666 + } 649 667 650 668 "AU$" => Token::unit(AUD), 651 669 "R$" => Token::unit(BRL),