MCPcopy Create free account
hub / github.com/audacity/audacity / EscapeJSON

Function EscapeJSON

libraries/lib-label-track/LabelTrack.cpp:563–581  ·  view source on GitHub ↗

Helper function to escape JSON special characters Podcast 2.0 Chapters spec requires proper JSON escaping

Source from the content-addressed store, hash-verified

561// Helper function to escape JSON special characters
562// Podcast 2.0 Chapters spec requires proper JSON escaping
563static wxString EscapeJSON(const wxString& input)
564{
565 wxString result;
566 result.reserve(input.length() * 2); // Reserve space for potential expansion
567 for (auto ch : input) {
568 wchar_t c = static_cast<wchar_t>(ch);
569 switch (c) {
570 case '\\': result += wxT("\\\\"); break;
571 case '"': result += wxT("\\\""); break;
572 case '\n': result += wxT("\\n"); break;
573 case '\r': result += wxT("\\r"); break;
574 case '\t': result += wxT("\\t"); break;
575 case '\b': result += wxT("\\b"); break;
576 case '\f': result += wxT("\\f"); break;
577 default: result += ch; break;
578 }
579 }
580 return result;
581}
582
583void LabelStruct::Export(wxTextFile &file, LabelFormat format, int index, bool isLast) const
584{

Callers 1

ExportMethod · 0.85

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected