Skip to content
Snippets Groups Projects
Commit 505e2f1d authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add strip_cp437_graphics() and have strip_ctrl() remove DEL chars too

strip_cp437_graphics() is like strip_exascii(), except it'll leave the foreign language characters and math symbols intact (removing just the common "block" and "line-drawing" characters).

DEL (0x7F) is a control character too, so have strip_ctrl() remove it.
parent 33b9e899
Branches
Tags
No related merge requests found
......@@ -68,7 +68,7 @@ char* strip_ctrl(const char *str, char* dest)
if(str[i]=='<' && j)
j--;
}
else if((uchar)str[i]>=' ')
else if((uchar)str[i]>=' ' && str[i] != DEL)
dest[j++]=str[i];
}
dest[j]=0;
......@@ -215,6 +215,20 @@ char* strip_exascii(const char *str, char* dest)
return dest;
}
char* strip_cp437_graphics(const char *str, char* dest)
{
int i,j;
if(dest==NULL && (dest=strdup(str))==NULL)
return NULL;
for(i=j=0;str[i];i++)
if((uchar)str[i] <= (uchar)CP437_INVERTED_EXCLAMATION_MARK
|| (uchar)str[i] >= (uchar)CP437_GREEK_SMALL_LETTER_ALPHA)
dest[j++]=str[i];
dest[j]=0;
return dest;
}
char* strip_space(const char *str, char* dest)
{
int i,j;
......
......@@ -55,6 +55,7 @@ DLLEXPORT str_list_t trashcan_list(scfg_t* cfg, const char* name);
DLLEXPORT char * convert_ansi(const char* src, char* dest, size_t, int width, BOOL ice_color);
DLLEXPORT char * strip_ansi(char* str);
DLLEXPORT char * strip_exascii(const char *str, char* dest);
DLLEXPORT char * strip_cp437_graphics(const char *str, char* dest);
DLLEXPORT char * strip_space(const char *str, char* dest);
DLLEXPORT char * strip_ctrl(const char *str, char* dest);
DLLEXPORT char * strip_char(const char* str, char* dest, char);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment