/* Support functions for Unicode implementation Copyright (C) 1997 Free Software Foundation, Inc. Written by: Stevo Crvenkovski Date: March 1997 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include struct _ucc_ {unichar from; char to;}; #include "unicode/cyrillic.h" #include "unicode/nextstep.h" #include "unicode/caseconv.h" #include "unicode/cop.h" #include "unicode/decomp.h" #define FALSE 0 #define TRUE 1 unichar encode_chartouni(char c, NSStringEncoding enc) { /* All that I could find in Next documentation on NSNonLossyASCIIStringEncoding was <>. */ if((enc==NSNonLossyASCIIStringEncoding) || (enc==NSASCIIStringEncoding) || (enc==NSISOLatin1StringEncoding)) return (unichar)((unsigned char)c); if((enc==NSNEXTSTEPStringEncoding)) if((unsigned char)c0) && (i0) && (i0) && (i0)&&(count0)&&(count (unichar)0x0080) // no nonspacing in ascii { while(notfound && (first <= last)) { if(!(first==last)) { count = (first + last) / 2; comp=uni_cop_table[count].code; if(comp < u) first = count+1; else if(comp > u) last = count-1; else notfound = FALSE; } else /* first==last */ { if(u == uni_cop_table[first].code) return uni_cop_table[first].cop; return 0; } /* else */ } /* while notfound ...*/ return notfound?0:uni_cop_table[count].cop; } else /* u is ascii */ return 0; } BOOL uni_isnonsp(unichar u) { #define TRUE 1 #define FALSE 0 // check is uni_cop good for this if(uni_cop(u)) return TRUE; else return FALSE; } unichar *uni_is_decomp(unichar u) { unichar count,first,last,comp; BOOL notfound; first = 0; last = uni_dec_table_size; notfound = TRUE; count=0; if(u > (unichar)0x0080) // no composites in ascii { while(notfound && (first <= last)) { if(!(first==last)) { count = (first + last) / 2; comp=uni_dec_table[count].code; if(comp < u) first = count+1; else if(comp > u) last = count-1; else notfound = FALSE; } else /* first==last */ { if(u == uni_dec_table[first].code) return uni_dec_table[first].decomp; return 0; } /* else */ } /* while notfound ...*/ return notfound?0:uni_dec_table[count].decomp; } else /* u is ascii */ return 0; }