| 437 | |
| 438 | |
| 439 | int ReadDelimitedText( wxString* aDest, const char* aSource ) |
| 440 | { |
| 441 | std::string utf8; // utf8 but without escapes and quotes. |
| 442 | bool inside = false; |
| 443 | const char* start = aSource; |
| 444 | char cc; |
| 445 | |
| 446 | while( (cc = *aSource++) != 0 ) |
| 447 | { |
| 448 | if( cc == '"' ) |
| 449 | { |
| 450 | if( inside ) |
| 451 | break; // 2nd double quote is end of delimited text |
| 452 | |
| 453 | inside = true; // first delimiter found, make note, do not copy |
| 454 | } |
| 455 | |
| 456 | else if( inside ) |
| 457 | { |
| 458 | if( cc == '\\' ) |
| 459 | { |
| 460 | cc = *aSource++; |
| 461 | |
| 462 | if( !cc ) |
| 463 | break; |
| 464 | |
| 465 | // do no copy the escape byte if it is followed by \ or " |
| 466 | if( cc != '"' && cc != '\\' ) |
| 467 | utf8 += '\\'; |
| 468 | |
| 469 | utf8 += cc; |
| 470 | } |
| 471 | else |
| 472 | { |
| 473 | utf8 += cc; |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | *aDest = From_UTF8( utf8.c_str() ); |
| 479 | |
| 480 | return aSource - start; |
| 481 | } |
| 482 | |
| 483 | |
| 484 | int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize ) |
no test coverage detected