From 8a47f3be5d8d097fa8f552faa21606f2ac58b2c3 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 16 Apr 2024 20:25:17 +0900 Subject: [PATCH] Fixes to Korean number representation --- src/main.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c7b050e..51a65c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,6 +88,10 @@ std::u8string value_to_korean(unsigned long long value) { std::u8string s; unsigned long long temp; + + bool requires_uc = false; + bool requires_man = false; + if(temp = (value / 1000000000000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } @@ -97,46 +101,52 @@ std::u8string value_to_korean(unsigned long long value) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(chun); + requires_uc = true; } if(temp = (value / 10000000000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(bec); + requires_uc = true; } if(temp = (value / 1000000000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(ship); + requires_uc = true; } if(temp = (value / 100000000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } - if(temp != 1) { s.append(digit_to_kword(temp)); } + if (temp > 0) { s.append(digit_to_kword(temp)); } s.append(uc); - } else if(!s.empty()) { - if(!s.empty()) { s.push_back(' '); } - s.append(il); + } else if (requires_uc) { + s.push_back(' '); s.append(uc); } if(temp = (value / 10000000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(chun); + requires_man = true; } if(temp = (value / 1000000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(bec); + requires_man = true; } if(temp = (value / 100000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(ship); + requires_man = true; } if(temp = (value / 10000) % 10; temp > 0) { if(!s.empty()) { s.push_back(' '); } if(temp != 1) { s.append(digit_to_kword(temp)); } s.append(man); - } else if(!s.empty()) { + } else if (requires_man) { + s.push_back(' '); s.append(man); } if(temp = (value / 1000) % 10; temp > 0) {