quoted_pair.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "quoted_pair.h"
  2. #include <util/generic/strbuf.h>
  3. namespace NUnicode {
  4. EUnicodeQuotedPairType ResolveUnicodeQuotedPair(wchar32 escapedSymbol, wchar32& symbol, TUnicodeSet& set) {
  5. switch (escapedSymbol) {
  6. case wchar32('a'): // \a -> U+0007 Bell
  7. symbol = wchar32('\a');
  8. return UQPT_SYMBOL;
  9. case wchar32('b'): // \b -> U+0008 Backspace
  10. symbol = wchar32('\b');
  11. return UQPT_SYMBOL;
  12. case wchar32('t'): // \t -> U+0009 Horizontal Tab
  13. symbol = wchar32('\t');
  14. return UQPT_SYMBOL;
  15. case wchar32('n'): // \n -> U+000A Line Feed
  16. symbol = wchar32('\n');
  17. return UQPT_SYMBOL;
  18. case wchar32('v'): // \v -> U+000B Vertical Tab
  19. symbol = wchar32('\v');
  20. return UQPT_SYMBOL;
  21. case wchar32('f'): // \f -> U+000C Form Feed
  22. symbol = wchar32('\f');
  23. return UQPT_SYMBOL;
  24. case wchar32('r'): // \r -> U+000D Carriage Return
  25. symbol = wchar32('\r');
  26. return UQPT_SYMBOL;
  27. case wchar32('s'):
  28. set.AddCategory(TStringBuf("Z"));
  29. return UQPT_SET;
  30. case wchar32('S'):
  31. set.Add(TUnicodeSet().AddCategory(TStringBuf("Z")).Invert());
  32. return UQPT_SET;
  33. case wchar32('w'):
  34. set.AddCategory(TStringBuf("L"));
  35. return UQPT_SET;
  36. case wchar32('W'):
  37. set.Add(TUnicodeSet().AddCategory(TStringBuf("L")).Invert());
  38. return UQPT_SET;
  39. case wchar32('d'):
  40. set.AddCategory(TStringBuf("Nd"));
  41. return UQPT_SET;
  42. case wchar32('D'):
  43. set.Add(TUnicodeSet().AddCategory(TStringBuf("Nd")).Invert());
  44. return UQPT_SET;
  45. default:
  46. symbol = escapedSymbol;
  47. return UQPT_SYMBOL;
  48. }
  49. }
  50. }