-
Notifications
You must be signed in to change notification settings - Fork 5
Function to encode strings #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
234c272
665707d
92cd2bc
087ef2b
28ea301
20d7f5e
4626491
1e13e72
e6a49b5
81026a7
d33c982
0fe8c7f
3a3b17a
b15161a
eeb211f
aea9a89
96769f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -390,3 +390,32 @@ size_t decode_html_entities_utf8(char *dest, const char *src) | |
| return (size_t)(to - dest); | ||
| } | ||
|
|
||
| int encode_html_entities(char *dest, const char *src) { | ||
| char *to = dest; | ||
| for( const char *from = src ; *from ; from++ ) { | ||
| int i = 9999; | ||
|
||
| if ( *from <= '+' ) { | ||
| sprintf(to,"%%%02x",*from); | ||
| to += 3; | ||
| continue; | ||
| } | ||
| if ( *from<='z' ) { | ||
| *to = *from; | ||
| to++; | ||
| continue; | ||
| } | ||
| //if ( *from=='\r' || *from=='\n' ) continue; | ||
| for( i=0 ; i<sizeof NAMED_ENTITIES / sizeof *NAMED_ENTITIES ; i++ ) | ||
| if ( *from == NAMED_ENTITIES[i][1][0] ) break; | ||
|
||
| if ( i<sizeof NAMED_ENTITIES / sizeof *NAMED_ENTITIES ) { | ||
| strcpy(to,NAMED_ENTITIES[i][0]); | ||
| to += strlen(NAMED_ENTITIES[i][0]); | ||
| } | ||
| else { | ||
| *to = *from; | ||
| to++; | ||
| } | ||
| } | ||
| *to = 0; | ||
| return strlen(dest); | ||
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return
sitze_tinstead ofintThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely agree. I'll commit the correction.