goel-skd commented on code in PR #760:
URL: https://github.com/apache/iceberg-cpp/pull/760#discussion_r3464444572
##########
src/iceberg/util/string_util.h:
##########
@@ -41,22 +40,24 @@ concept FromChars = requires(const char* p, T& v) {
std::from_chars(p, p, v); };
class ICEBERG_EXPORT StringUtils {
public:
- // NOTE: These convert ASCII letters only; all other bytes, including
non-ASCII
- // (multibyte UTF-8) bytes, are passed through unchanged.
- // See https://github.com/apache/iceberg-cpp/issues/613.
- static std::string ToLower(std::string_view str) {
- return str | std::ranges::views::transform(ToLowerAscii) |
- std::ranges::to<std::string>();
- }
-
+ /// \brief Lower-case a UTF-8 string using Unicode simple case mapping.
+ ///
+ /// Mirrors Iceberg Java's case-insensitive handling, which lower-cases
names with
+ /// toLowerCase(Locale.ROOT). Invalid UTF-8 input is returned unchanged.
+ /// See https://github.com/apache/iceberg-cpp/issues/613.
+ static std::string ToLower(std::string_view str);
+
+ /// \brief Upper-case ASCII letters; non-ASCII (multibyte UTF-8) bytes pass
through
+ /// unchanged.
+ ///
+ /// Unlike ToLower this is ASCII-only, since upper-casing is not used for
name matching.
Review Comment:
ASCII is a subset of UTF-8, so the UTF-8 ```ToLower``` is already correct on
ASCII input. A ```ToLowerAscii``` wouldn't be more correct, only faster on
known-ASCII data, and it makes the caller decide "is my input ASCII?", which is
sort of a foot-gun. One ToLower also matches Iceberg Java, which only has
toLowerCase(Locale.ROOT) with no ascii/utf8 split.
I suggest that we skip ```ToUpperUtf8``` either way. Simple-mapping
uppercase is just wrong for things like ß (stays ß, should be SS), and nothing
here uppercases non-ASCII anyway. The two ```ToUpper``` callers just normalize
codec/mode strings to match GZIP/ALL.
You're right it's misleading though. I'll rename ```ToUpper ->
ToUpperAscii``` so it's in the name, and keep ```ToLower``` as the Unicode one.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]