MCPcopy Create free account
hub / github.com/buggins/coolreader / DecodeHTMLUrlString

Function DecodeHTMLUrlString

crengine/src/lvstring.cpp:4008–4042  ·  view source on GitHub ↗

decodes path like "file%20name" to "file name"

Source from the content-addressed store, hash-verified

4006
4007/// decodes path like "file%20name" to "file name"
4008lString16 DecodeHTMLUrlString( lString16 s )
4009{
4010 const lChar16 * str = s.c_str();
4011 for ( int i=0; str[i]; i++ ) {
4012 if ( str[i]=='%' ) {
4013 int ch = decodeHTMLChar( str + i );
4014 if ( ch==0 ) {
4015 continue;
4016 }
4017 // HTML encoded char found
4018 lString16 res;
4019 res.reserve(s.length());
4020 res.append(str, i);
4021 res.append(1, ch);
4022 i+=3;
4023
4024 // continue conversion
4025 for ( ; str[i]; i++ ) {
4026 if ( str[i]=='%' ) {
4027 ch = decodeHTMLChar( str + i );
4028 if ( ch==0 ) {
4029 res.append(1, str[i]);
4030 continue;
4031 }
4032 res.append(1, ch);
4033 i+=2;
4034 } else {
4035 res.append(1, str[i]);
4036 }
4037 }
4038 return res;
4039 }
4040 }
4041 return s;
4042}
4043
4044void limitStringSize(lString16 & str, int maxSize) {
4045 if ((int) str.length() < maxSize)

Callers 2

getHRefMethod · 0.85
getObjectImageRefNameMethod · 0.85

Calls 5

decodeHTMLCharFunction · 0.85
c_strMethod · 0.45
reserveMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected