MCPcopy Create free account
hub / github.com/cinder/Cinder / encode

Method encode

src/cinder/Url.cpp:99–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99std::string Url::encode( const std::string &unescaped )
100{
101#if defined( CINDER_COCOA )
102 cocoa::SafeCfString unescapedStr = cocoa::createSafeCfString( unescaped );
103 CFStringRef escaped = ::CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, unescapedStr.get(), NULL, NULL, kCFStringEncodingUTF8 );
104 std::string result = cocoa::convertCfString( escaped );
105 ::CFRelease( escaped );
106 return result;
107#elif defined( CINDER_MSW_DESKTOP )
108 char16_t buffer[4096];
109 DWORD bufferSize = 4096;
110 std::u16string wideUnescaped = toUtf16( unescaped );
111 UrlEscape( (wchar_t*)wideUnescaped.c_str(), (wchar_t*)buffer, &bufferSize, 0 );
112 return toUtf8( buffer );
113#elif defined( CINDER_ANDROID )
114 std::string result = urlencode( unescaped );
115 return result;
116#elif defined( CINDER_LINUX )
117 // Curl does not seem to agree with encoded URIs.
118 return unescaped;
119#endif
120}
121
122
123//////////////////////////////////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 5

toUtf16Function · 0.85
urlencodeFunction · 0.85
toUtf8Function · 0.70
getMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected