From: <baz...@us...> - 2009-01-18 22:55:31
|
Revision: 8857 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8857&view=rev Author: bazaarmagetron Date: 2009-01-18 21:39:11 +0000 (Sun, 18 Jan 2009) Log Message: ----------- Manuel Moos: tCharacterFilter and its users now work with utf8. Modified Paths: -------------- armagetronad/branches/utf8/armagetronad/src/engine/ePlayer.cpp armagetronad/branches/utf8/armagetronad/src/network/nNetwork.cpp armagetronad/branches/utf8/armagetronad/src/tools/tString.cpp armagetronad/branches/utf8/armagetronad/src/tools/tString.h Property Changed: ---------------- armagetronad/branches/utf8/armagetronad/ Property changes on: armagetronad/branches/utf8/armagetronad ___________________________________________________________________ Modified: bzr:revision-info - timestamp: 2009-01-18 20:22:33.319000006 +0100 committer: Manuel Moos <z-...@us...> properties: branch-nick: armagetronad + timestamp: 2009-01-18 22:31:08.217999935 +0100 committer: Manuel Moos <z-...@us...> properties: branch-nick: armagetronad Modified: bzr:file-ids - src/tron/gWinZone.h 8853@7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:src%2Ftron%2FgWinZone.h src/tron/gWinZone.cpp 8853@7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Ftrunk%2Farmagetronad:src%2Ftron%2FgWinZone.cpp + Modified: bzr:revision-id:v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs - 613 z-...@us...-20080211141509-cwbrb6hmtz9313jr 626 z-...@us...-20080214170110-rhfpd874zuogr3cm 627 z-...@us...-20080214170244-1gstsfe9yzyvrx9b 657 z-...@us...-20080301093905-0jwh1zg9srukp8fn 678 wrt...@us...-20080320130546-cr72y7d9q5a8nk7a 679 z-...@us...-20080324202056-eybvkm0gjomywbcq 680 z-...@us...-20080326104303-kpkkrwiw1fioi0rd 681 epsy-20080327213346-setzm7umdzzuk2dm 683 wrt...@us...-20080402122117-54nak33inuca02o9 684 wrt...@us...-20080402122804-2xhc8bgyrjsa09cd 685 wrt...@us...-20080418093840-cxtpql4xw2vsbmyn 686 ep...@fr...-20080418200503-q16s8az3yewn4x7a 687 ep...@fr...-20080419004917-bq4vguy9vpbkmlo3 688 wrt...@us...-20080419185850-ksm1feadrrhqigjb 689 wrt...@us...-20080423170738-zb8v72r0asm7cp52 691 ep...@fr...-20080427145818-212ave5ohdhth4ph 692 epsy46-20080428164518-07b9wsj90rf82c3y 693 epsy46-20080429194430-hq3fd6i1mnz1vrnz 694 ep...@fr...-20080518131839-uik8hj18c55boh3m 696 z-...@us...-20080618212520-e6ov1rb9b9edwt30 697 wrt...@us...-20080708142300-tu6f7ag7ak0yhdrf 698 wrt...@us...-20080727173310-pv1vq0wj01yfwgfl 699 da...@da...-20080824021014-8aacq5gfp7ktxlxz 700 da...@da...-20080824055426-l5dwhb216uteu7ca 701 da...@da...-20080824172432-lvagd99j28hq8uc1 702 da...@da...-20080824225545-ply97boo9jkqtysn 704 ep...@fr...-20081027173216-nh6d92edtwe35j2g 705 ep...@fr...-20081027203505-42bpegw0fyywzyou 706 ep...@fr...-20081027204727-jcx89jukht9ay72r 707 ep...@fr...-20081028180734-62o6e90rf020xzv8 708 ep...@fr...-20081028224044-f3myemuy87v52ilp 709 ep...@fr...-20081110193848-iksu9rmzzi7jb0qq 710 ep...@fr...-20081114212232-i1q12n375bdpl0sp 712 z-...@us...-20081211141049-wbjceadupsfss5ib 713 da...@da...-20081216223143-1hso83uxyagaubg8 716 lee...@gm...-20081220084635-zv6bpm9rar9yufy7 717 lee...@gm...-20081220085046-6rwe6cqmdlffs4rl 718 lee...@gm...-20081220085502-gpad43pu99t1e6po 719 lee...@gm...-20081220092821-q7uj4w92j6a3a7eb 720 lee...@gm...-20081220094339-k3zb139qp87r4b2w 721 lee...@gm...-20081220100858-uap7k5s22tbipzkt 722 lee...@gm...-20081220111203-rhp5p15agx73xi1k 723 lee...@gm...-20081220112757-mjp2yffddjy5s74e 724 lee...@gm...-20081220114653-k2dqt4wiizipbwas 725 lee...@gm...-20081221181637-6d0tfx7sx7syxfb6 726 lee...@gm...-20081221182603-9bkelm9x7aclb0bw 734 lee...@gm...-20081230173103-fmzio9fanap2rybf 735 lee...@gm...-20081230174204-cppkz4sumguhysa9 736 lee...@gm...-20081230174738-mecjttlpyp1i859c 737 lee...@gm...-20081230174816-qmtp2a3q8m52jsn3 738 lee...@gm...-20081230194247-q6oyx6cqfz03b2lr 739 lee...@gm...-20081231202038-odzabc3wmlqzvskt 740 lee...@gm...-20081231203835-nn2kezh1el82dn1q 741 lee...@gm...-20090101022727-myjxnrvqe5e4l1wz 743 da...@da...-20090103170253-cdtppjz8nzwhngst 744 da...@da...-20090103183413-r1852m22og3lh2uc 745 lee...@gm...-20090103212852-mvsergjd4ao1la77 746 da...@da...-20090103231550-6zn9qzo6gpj9kwu8 748 da...@da...-20090105115751-x3y9oui4xvt43crj 749 da...@da...-20090105131244-nljbq3qp4hp7lg07 750 da...@da...-20090105192648-inoxhljmqqe3dgw7 751 da...@da...-20090105192806-vhrs9hj8nr4lrdp0 752 da...@da...-20090106194428-nwwwyljr8wn3pwq1 753 da...@da...-20090106194753-82zu5xfqfzbnk9k9 754 da...@da...-20090106202104-5z9836ych2di2jlo 755 da...@da...-20090106234335-aolp3kr0gasjmbri 756 da...@da...-20090106234811-p3el5s40j0upvyql 757 da...@da...-20090107021107-5kbemotp1sco4ncp 758 da...@da...-20090107051447-8ncvyikf3aadgz3a 759 da...@da...-20090107071255-jhqi9p9212levb60 760 z-...@us...-20090107105902-l6x07af4hr2py066 761 z-...@us...-20090107111842-2o0fqp72oxz55jri 762 z-...@us...-20090107113141-mo1g3b0jgzhyj001 763 z-...@us...-20090107113517-dsyf4f6jroj6dr9e 764 z-...@us...-20090107114151-9n5m6mvsq9nh33p1 770 z-...@us...-20090111232523-lnab7ymhxk94pdh1 771 z-...@us...-20090111232619-ukmmx5gfarcoiipi 772 z-...@us...-20090111233014-dazt93cibmg56v3i 774 z-...@us...-20090112103858-psygqhxdmdaer8iz 775 z-...@us...-20090112104018-jik2mqnc14fg5bdk 776 z-...@us...-20090112104123-hvkx0sxhs9wz706b 777 z-...@us...-20090112114514-v1u04w5v83ai75lz 778 z-...@us...-20090112115926-ltqy35euxny3n7zc 779 lee...@gm...-20090112192634-vs5qzckrwxphs3k5 780 lee...@gm...-20090112194338-2zfak9nrxm961yh5 781 lee...@gm...-20090112194729-dlonazcnq20npwqk 782 lee...@gm...-20090112211701-prgmu1fh3p33tz1j 783 lee...@gm...-20090112212513-ojbb1zz98kk1mmzf 784 lee...@gm...-20090112214315-r8akrgn38um8llfc 785 z-...@us...-20090115005714-uscid6wcwnjqzcht 787 z-...@us...-20090116155610-s9rvqacdyl4uu2ym 788 z-...@us...-20090116160116-47he0b9dhkvzfo8e 789 z-...@us...-20090116160130-yu0foyldpp0w651o 795 z-...@us...-20090117122344-comx3bxy0d41qpwd 796 mathias@earth-20090117150753-nhe4uiepl6tygf3i 797 z-...@us...-20090117195331-6gc1v90xckw6hscm 798 z-...@us...-20090117203629-of7hakl55vftnfiy 799 z-...@us...-20090117204902-42gcsuz3i4gxnfjn 800 z-...@us...-20090117214725-sas6xmcy28cfdf5j 801 z-...@us...-20090117214905-nagdvts9p9avev4n 802 z-...@us...-20090117234325-da4cduc5if9isv09 803 z-...@us...-20090117234342-9n4gkfl4uq07bmbp 804 z-...@us...-20090118013638-zk6n9i23iy3kikcs 805 z-...@us...-20090118192233-p8y9d18pgsjwpk3f + 613 z-...@us...-20080211141509-cwbrb6hmtz9313jr 626 z-...@us...-20080214170110-rhfpd874zuogr3cm 627 z-...@us...-20080214170244-1gstsfe9yzyvrx9b 657 z-...@us...-20080301093905-0jwh1zg9srukp8fn 678 wrt...@us...-20080320130546-cr72y7d9q5a8nk7a 679 z-...@us...-20080324202056-eybvkm0gjomywbcq 680 z-...@us...-20080326104303-kpkkrwiw1fioi0rd 681 epsy-20080327213346-setzm7umdzzuk2dm 683 wrt...@us...-20080402122117-54nak33inuca02o9 684 wrt...@us...-20080402122804-2xhc8bgyrjsa09cd 685 wrt...@us...-20080418093840-cxtpql4xw2vsbmyn 686 ep...@fr...-20080418200503-q16s8az3yewn4x7a 687 ep...@fr...-20080419004917-bq4vguy9vpbkmlo3 688 wrt...@us...-20080419185850-ksm1feadrrhqigjb 689 wrt...@us...-20080423170738-zb8v72r0asm7cp52 691 ep...@fr...-20080427145818-212ave5ohdhth4ph 692 epsy46-20080428164518-07b9wsj90rf82c3y 693 epsy46-20080429194430-hq3fd6i1mnz1vrnz 694 ep...@fr...-20080518131839-uik8hj18c55boh3m 696 z-...@us...-20080618212520-e6ov1rb9b9edwt30 697 wrt...@us...-20080708142300-tu6f7ag7ak0yhdrf 698 wrt...@us...-20080727173310-pv1vq0wj01yfwgfl 699 da...@da...-20080824021014-8aacq5gfp7ktxlxz 700 da...@da...-20080824055426-l5dwhb216uteu7ca 701 da...@da...-20080824172432-lvagd99j28hq8uc1 702 da...@da...-20080824225545-ply97boo9jkqtysn 704 ep...@fr...-20081027173216-nh6d92edtwe35j2g 705 ep...@fr...-20081027203505-42bpegw0fyywzyou 706 ep...@fr...-20081027204727-jcx89jukht9ay72r 707 ep...@fr...-20081028180734-62o6e90rf020xzv8 708 ep...@fr...-20081028224044-f3myemuy87v52ilp 709 ep...@fr...-20081110193848-iksu9rmzzi7jb0qq 710 ep...@fr...-20081114212232-i1q12n375bdpl0sp 712 z-...@us...-20081211141049-wbjceadupsfss5ib 713 da...@da...-20081216223143-1hso83uxyagaubg8 716 lee...@gm...-20081220084635-zv6bpm9rar9yufy7 717 lee...@gm...-20081220085046-6rwe6cqmdlffs4rl 718 lee...@gm...-20081220085502-gpad43pu99t1e6po 719 lee...@gm...-20081220092821-q7uj4w92j6a3a7eb 720 lee...@gm...-20081220094339-k3zb139qp87r4b2w 721 lee...@gm...-20081220100858-uap7k5s22tbipzkt 722 lee...@gm...-20081220111203-rhp5p15agx73xi1k 723 lee...@gm...-20081220112757-mjp2yffddjy5s74e 724 lee...@gm...-20081220114653-k2dqt4wiizipbwas 725 lee...@gm...-20081221181637-6d0tfx7sx7syxfb6 726 lee...@gm...-20081221182603-9bkelm9x7aclb0bw 734 lee...@gm...-20081230173103-fmzio9fanap2rybf 735 lee...@gm...-20081230174204-cppkz4sumguhysa9 736 lee...@gm...-20081230174738-mecjttlpyp1i859c 737 lee...@gm...-20081230174816-qmtp2a3q8m52jsn3 738 lee...@gm...-20081230194247-q6oyx6cqfz03b2lr 739 lee...@gm...-20081231202038-odzabc3wmlqzvskt 740 lee...@gm...-20081231203835-nn2kezh1el82dn1q 741 lee...@gm...-20090101022727-myjxnrvqe5e4l1wz 743 da...@da...-20090103170253-cdtppjz8nzwhngst 744 da...@da...-20090103183413-r1852m22og3lh2uc 745 lee...@gm...-20090103212852-mvsergjd4ao1la77 746 da...@da...-20090103231550-6zn9qzo6gpj9kwu8 748 da...@da...-20090105115751-x3y9oui4xvt43crj 749 da...@da...-20090105131244-nljbq3qp4hp7lg07 750 da...@da...-20090105192648-inoxhljmqqe3dgw7 751 da...@da...-20090105192806-vhrs9hj8nr4lrdp0 752 da...@da...-20090106194428-nwwwyljr8wn3pwq1 753 da...@da...-20090106194753-82zu5xfqfzbnk9k9 754 da...@da...-20090106202104-5z9836ych2di2jlo 755 da...@da...-20090106234335-aolp3kr0gasjmbri 756 da...@da...-20090106234811-p3el5s40j0upvyql 757 da...@da...-20090107021107-5kbemotp1sco4ncp 758 da...@da...-20090107051447-8ncvyikf3aadgz3a 759 da...@da...-20090107071255-jhqi9p9212levb60 760 z-...@us...-20090107105902-l6x07af4hr2py066 761 z-...@us...-20090107111842-2o0fqp72oxz55jri 762 z-...@us...-20090107113141-mo1g3b0jgzhyj001 763 z-...@us...-20090107113517-dsyf4f6jroj6dr9e 764 z-...@us...-20090107114151-9n5m6mvsq9nh33p1 770 z-...@us...-20090111232523-lnab7ymhxk94pdh1 771 z-...@us...-20090111232619-ukmmx5gfarcoiipi 772 z-...@us...-20090111233014-dazt93cibmg56v3i 774 z-...@us...-20090112103858-psygqhxdmdaer8iz 775 z-...@us...-20090112104018-jik2mqnc14fg5bdk 776 z-...@us...-20090112104123-hvkx0sxhs9wz706b 777 z-...@us...-20090112114514-v1u04w5v83ai75lz 778 z-...@us...-20090112115926-ltqy35euxny3n7zc 779 lee...@gm...-20090112192634-vs5qzckrwxphs3k5 780 lee...@gm...-20090112194338-2zfak9nrxm961yh5 781 lee...@gm...-20090112194729-dlonazcnq20npwqk 782 lee...@gm...-20090112211701-prgmu1fh3p33tz1j 783 lee...@gm...-20090112212513-ojbb1zz98kk1mmzf 784 lee...@gm...-20090112214315-r8akrgn38um8llfc 785 z-...@us...-20090115005714-uscid6wcwnjqzcht 787 z-...@us...-20090116155610-s9rvqacdyl4uu2ym 788 z-...@us...-20090116160116-47he0b9dhkvzfo8e 789 z-...@us...-20090116160130-yu0foyldpp0w651o 795 z-...@us...-20090117122344-comx3bxy0d41qpwd 796 mathias@earth-20090117150753-nhe4uiepl6tygf3i 797 z-...@us...-20090117195331-6gc1v90xckw6hscm 798 z-...@us...-20090117203629-of7hakl55vftnfiy 799 z-...@us...-20090117204902-42gcsuz3i4gxnfjn 800 z-...@us...-20090117214725-sas6xmcy28cfdf5j 801 z-...@us...-20090117214905-nagdvts9p9avev4n 802 z-...@us...-20090117234325-da4cduc5if9isv09 803 z-...@us...-20090117234342-9n4gkfl4uq07bmbp 804 z-...@us...-20090118013638-zk6n9i23iy3kikcs 805 z-...@us...-20090118192233-p8y9d18pgsjwpk3f 806 z-...@us...-20090118213108-p1nhbalpb5z1yjtz Modified: armagetronad/branches/utf8/armagetronad/src/engine/ePlayer.cpp =================================================================== --- armagetronad/branches/utf8/armagetronad/src/engine/ePlayer.cpp 2009-01-18 19:31:38 UTC (rev 8856) +++ armagetronad/branches/utf8/armagetronad/src/engine/ePlayer.cpp 2009-01-18 21:39:11 UTC (rev 8857) @@ -8397,18 +8397,10 @@ void ePlayerNetID::FilterName( tString const & in, tString & out ) { - int i; static ePlayerCharacterFilter filter; - out = tColoredString::RemoveColors( in ); + tString temp = tColoredString::RemoveColors( in ); + out = filter.FilterString( temp ); - // filter out illegal characters - for ( i = out.Size()-1; i>=0; --i ) - { - char & c = out[i]; - - c = filter.Filter( c ); - } - // strip leading and trailing unknown characters se_StripMatchingEnds( out, se_IsUnderscore, se_IsUnderscore ); } Modified: armagetronad/branches/utf8/armagetronad/src/network/nNetwork.cpp =================================================================== --- armagetronad/branches/utf8/armagetronad/src/network/nNetwork.cpp 2009-01-18 19:31:38 UTC (rev 8856) +++ armagetronad/branches/utf8/armagetronad/src/network/nNetwork.cpp 2009-01-18 21:39:11 UTC (rev 8857) @@ -1249,19 +1249,6 @@ // read the raw data ReadRaw( s ); - // filter client string messages - if ( sn_GetNetState() == nSERVER ) - { - s.NetFilter(); - s.RemoveTrailingColor(); - } - - // filter color codes away - if ( sn_filterColorStrings ) - s = tColoredString::RemoveColors( s, false ); - else if ( sn_filterDarkColorStrings ) - s = tColoredString::RemoveColors( s, true ); - // convert latin1 encoding to utf8 // The server knows which clients support unicode precisely; every unicode supporting client // sends in utf8 to a unicode supporting server. However, the server has to send back latin1 @@ -1285,6 +1272,19 @@ } */ + // filter client string messages + if ( sn_GetNetState() == nSERVER ) + { + s.NetFilter(); + s.RemoveTrailingColor(); + } + + // filter color codes away + if ( sn_filterColorStrings ) + s = tColoredString::RemoveColors( s, false ); + else if ( sn_filterDarkColorStrings ) + s = tColoredString::RemoveColors( s, true ); + return *this; } Modified: armagetronad/branches/utf8/armagetronad/src/tools/tString.cpp =================================================================== --- armagetronad/branches/utf8/armagetronad/src/tools/tString.cpp 2009-01-18 19:31:38 UTC (rev 8856) +++ armagetronad/branches/utf8/armagetronad/src/tools/tString.cpp 2009-01-18 21:39:11 UTC (rev 8857) @@ -34,6 +34,7 @@ #include <ctype.h> #include <string> #include <iostream> +#include "utf8.h" // ******************************************************************************* // * @@ -1669,10 +1670,53 @@ void tString::NetFilter( void ) { - static tNetCharacterFilter filter; + // output string + tString out; - // run through string - *this = filter.FilterString( *this ); + // prepare reader and writer + tString::iterator reader = begin(); + std::back_insert_iterator< tString > writer = back_inserter(out); + + try + { + // filter out illegal characters + while( reader != end() ) + { + // convert from utf8 + wchar_t c = utf8::next( reader, end() ); + + // ignore backspace + if ( c != 0x7f ) + { + // filter + if ( isblank(c) ) + { + // unify whitespace to regular space + c = ' '; + } + else if ( c < 32 ) + { + // nonprintable characters -> underscore + c = '_'; + } + // everything else is legal. + + // convert back to utf8 + utf8::append( c, writer ); + } + } + } + catch(...) + { + // just leave the conversion incomplete in case of encoding errors + + // but not in debug mode. This shoudln't happen. +#ifdef DEBUG + tERR_ERROR( "Invalid utf8 strings in the system." ); +#endif + } + + *this = out; } bool st_colorStrings=true; @@ -2265,14 +2309,22 @@ //! // ********************************************************************** -char tCharacterFilter::Filter( unsigned char in ) +wchar_t tCharacterFilter::Filter( wchar_t in ) { - return filter[ in ]; + if ( in < filter.Len() ) + { + return filter[ in ]; + } + else + { + // unknown characters get mapped to underscores. + return '_'; + } } // ********************************************************************** // * -// * Filter +// * FilterByteString // * // ********************************************************************** //! @@ -2280,7 +2332,7 @@ //! // ********************************************************************** -tString tCharacterFilter::FilterString( tString & s ) +tString tCharacterFilter::FilterByteString( tString & s ) { int len = s.Len() -1; tString out; @@ -2293,28 +2345,54 @@ out << c; } } - // std::cout << "Filtered name for " /*<< ( IP? "IP ":"" )*/ << "'" << s << "' : '" << out << "'\n"; return out; } // ********************************************************************** // * -// * SetMap +// * FilterString // * // ********************************************************************** //! -//! @param in1 Begin of the character range to process filters on -//! @param in2 End of the character range -//! @param out Filtered character +//! @param in Character to process filters on //! // ********************************************************************** -void tCharacterFilter::SetMap( unsigned char in1, unsigned char in2, unsigned char out) +tString tCharacterFilter::FilterString( tString & s ) { - tASSERT( in1 < in2 ); - for( unsigned char i = in2; i >= in1; --i ) - filter[ i ] = out; + // output string + tString out; + + // prepare reader and writer + tString::iterator reader = s.begin(); + std::back_insert_iterator< tString > writer = back_inserter(out); + + try + { + // filter out illegal characters + while( reader != s.end() ) + { + // convert from utf8 + wchar_t c = utf8::next( reader, s.end() ); + if ( c != 0x7f ) + { + // filter and convert back to utf8 + utf8::append( Filter( c ), writer ); + } + } + } + catch(...) + { + // just leave the conversion incomplete in case of encoding errors + + // but not in debug mode. This shoudln't happen. +#ifdef DEBUG + tERR_ERROR( "Invalid utf8 strings in the system." ); +#endif + } + + return out; } // ********************************************************************** @@ -2323,47 +2401,39 @@ // * // ********************************************************************** //! -//! @param in Character to process filters on +//! @param in1 Begin of the character range to process filters on +//! @param in2 End of the character range //! @param out Filtered character //! // ********************************************************************** -void tCharacterFilter::SetMap( unsigned char in, unsigned char out ) +void tCharacterFilter::SetMap( wchar_t in1, wchar_t in2, wchar_t out) { - filter[ in ] = out; + // fill gaps with underscores + for( wchar_t i = filter.Len(); i < in1; ++i ) + { + filter[ i ] = '_'; + } + + tASSERT( in1 <= in2 ); + for( wchar_t i = in2; i >= in1; --i ) + filter[ i ] = out; } // ********************************************************************** // * -// * tNetCharacterFilter +// * SetMap // * // ********************************************************************** //! +//! @param in Character to process filters on +//! @param out Filtered character //! // ********************************************************************** -tNetCharacterFilter::tNetCharacterFilter ( void ) +void tCharacterFilter::SetMap( wchar_t in, wchar_t out ) { - unsigned int i; - filter[0]=0; - - // map all unknown characters to underscores - for (i=255; i > 0; i--) - { - filter[i] = '_'; - } - - // no, leave all ISO Latin 1 characters as they are - for (i=255; i >= 32; --i) - { - filter[i] = i; - } - - // map return and tab to space - SetMap('\n',' '); - SetMap('\t',' '); - - + SetMap( in, in, out ); } tString st_GetCurrentTime( char const * szFormat ) Modified: armagetronad/branches/utf8/armagetronad/src/tools/tString.h =================================================================== --- armagetronad/branches/utf8/armagetronad/src/tools/tString.h 2009-01-18 19:31:38 UTC (rev 8856) +++ armagetronad/branches/utf8/armagetronad/src/tools/tString.h 2009-01-18 21:39:11 UTC (rev 8857) @@ -33,6 +33,8 @@ #include "defs.h" +#include "tArray.h" + #include <string> #include <sstream> #include <iostream> @@ -296,23 +298,23 @@ class tCharacterFilter { public: - char Filter ( unsigned char ); + // filter a single character + wchar_t Filter ( wchar_t ); + + // filter a whole string, byte for byte + tString FilterByteString ( tString & ); + + // filter a whole utf8 string tString FilterString ( tString & ); protected: - tCharacterFilter ( void ) {} // To use a tCharacterFilter, make your own class herit of this one and define the constructor + tCharacterFilter ( void ) {} // To use a tCharacterFilter, make your own class inherit of this one and define the constructor - void SetMap ( unsigned char, unsigned char, unsigned char ); - void SetMap ( unsigned char, unsigned char ); + void SetMap ( wchar_t, wchar_t, wchar_t ); + void SetMap ( wchar_t, wchar_t ); - char filter[256]; + tArray< wchar_t > filter; }; -class tNetCharacterFilter: public tCharacterFilter -{ -public: - tNetCharacterFilter ( void ); -}; - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |