| 217 | } |
| 218 | |
| 219 | void ParseString(IStringReader* reader) |
| 220 | { |
| 221 | auto sb = StringBuilder(); |
| 222 | codepoint_t codepoint; |
| 223 | |
| 224 | // Parse string identifier |
| 225 | while (reader->TryPeek(&codepoint)) |
| 226 | { |
| 227 | if (IsNewLine(codepoint)) |
| 228 | { |
| 229 | // Unexpected new line, ignore line entirely |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | if (!IsWhitespace(codepoint) && codepoint != ':') |
| 234 | { |
| 235 | reader->Skip(); |
| 236 | sb.Append(codepoint); |
| 237 | } |
| 238 | else |
| 239 | { |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | SkipWhitespace(reader); |
| 245 | |
| 246 | // Parse a colon |
| 247 | if (!reader->TryPeek(&codepoint) || codepoint != ':') |
| 248 | { |
| 249 | // Expected a colon, ignore line entirely |
| 250 | return; |
| 251 | } |
| 252 | reader->Skip(); |
| 253 | |
| 254 | // Validate identifier |
| 255 | const utf8* identifier = sb.GetBuffer(); |
| 256 | |
| 257 | int32_t stringId; |
| 258 | if (sscanf(identifier, "STR_%4d", &stringId) != 1) |
| 259 | { |
| 260 | // Ignore line entirely |
| 261 | return; |
| 262 | } |
| 263 | |
| 264 | // Rest of the line is the actual string |
| 265 | sb.Clear(); |
| 266 | while (reader->TryPeek(&codepoint) && !IsNewLine(codepoint)) |
| 267 | { |
| 268 | reader->Skip(); |
| 269 | sb.Append(codepoint); |
| 270 | } |
| 271 | |
| 272 | std::string s; |
| 273 | if (LanguagesDescriptors[_id].isRtl) |
| 274 | { |
| 275 | auto ts = std::string(sb.GetBuffer(), sb.GetLength()); |
| 276 | s = FixRTL(ts); |