We need to implement a compact service that accepts text strings and returns a summary for each line. The service is used in code where the input may be in UTF-8 or Windows-1251, and the output needs to be stable UTF-8.
LineSummary.build(lines) method accepts an array of strings and returns an array of hashes.text — the string in UTF-8bytes — the number of bytes after normalization to UTF-8uppercase — the string in uppercaseUTF-8, its contents must not change.UTF-8.LineSummary.build where the first string is UTF-8 and the second is created as Windows-1251.text and bytes in the result.Input example:
utf8 = "Привет"
cp1251 = "Привет".encode("Windows-1251")
LineSummary.build([utf8, cp1251])
bytes must be calculated from the normalized UTF-8 string.ruby -Ilib or an equivalent test runner without extra gemsUse line comments to explain the problem, its impact, the fix and how to test it.