| 327 | } |
| 328 | |
| 329 | string FormatTextToken(const DateTimeFormatToken& tok) { |
| 330 | DCHECK(tok.type == TEXT); |
| 331 | string result; |
| 332 | result.reserve(tok.len); |
| 333 | for (const char* text_it = tok.val; text_it < tok.val + tok.len; ++text_it) { |
| 334 | if (*text_it != '\\') { |
| 335 | result.append(text_it, 1); |
| 336 | continue; |
| 337 | } |
| 338 | if (tok.is_double_escaped && strncmp(text_it, "\\\\\\\"", 4) == 0) { |
| 339 | result.append("\""); |
| 340 | text_it += 3; |
| 341 | } else if (!tok.is_double_escaped && strncmp(text_it, "\\\"", 2) == 0) { |
| 342 | result.append("\""); |
| 343 | ++text_it; |
| 344 | } else if (strncmp(text_it, "\\\\", 2) == 0) { |
| 345 | result.append("\\"); |
| 346 | ++text_it; |
| 347 | } else if (strncmp(text_it, "\\b", 2) == 0) { |
| 348 | result.append("\b"); |
| 349 | ++text_it; |
| 350 | } else if (strncmp(text_it, "\\n", 2) == 0) { |
| 351 | result.append("\n"); |
| 352 | ++text_it; |
| 353 | } else if (strncmp(text_it, "\\r", 2) == 0) { |
| 354 | result.append("\r"); |
| 355 | ++text_it; |
| 356 | } else if (strncmp(text_it, "\\t", 2) == 0) { |
| 357 | result.append("\t"); |
| 358 | ++text_it; |
| 359 | } |
| 360 | } |
| 361 | return result; |
| 362 | } |
| 363 | |
| 364 | const string& FormatMonthName(int num_of_month, const DateTimeFormatToken& tok) { |
| 365 | DCHECK(num_of_month >= 1 && num_of_month <= 12); |