/***************************************************************************
KCharsets.h - description
-------------------
begin : Tue Mar 14 2000
copyright : (C) 2000 by Richard Dale
email : Richard_Dale@tipitina.demon.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KCHARSETS_H
#define KCHARSETS_H
#include <Foundation/NSObject.h>
#include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
#include <qtobjc/QFont.h>
/**
*@author Richard Dale
*/
@class Kcharset;
@interface KCharset : NSObject
/**
* Default initializer
*/
- init;
/**
* Prepares charset of given name
*
* @param name Name of the charset
*/
- initFromName: (NSString *) name;
/**
* Copy a KCharset
*/
- initFromCharset: (KCharset *) charset;
/**
* Prepares charset from Qt's charset id
*
* @param id Qt's id of the charset
*/
- initFromQtCharset: (int) charset;
/**
* Gives name of the charset
*
* @return name of the charset
*/
- (NSString *) name;
/**
* Check if charset is displayable
*
* @return YES if it is displayable
*/
- (BOOL) isDisplayable;
/**
* Check if charset is displayable using given font
*
* @param family name of the font
* @return YES if it is displayable
*/
- (BOOL) isDisplayable: (NSString *) font;
/**
* Check if charset is defined for use with KDE (in charsets
* classes or in charsets config files)
*
* @return YES if it is available
*/
- (BOOL) isAvailable;
/**
* Check if charset is OK.
* In fact the same as @ref isAvailable
*
* @return YES if it is available
*/
- (BOOL) ok;
/**
* Check if charset is registered for use in mime messages.
* YES also for some not-yet-registered charsets (UTF-7 and UTF-8)
*
* @return YES if it is registered
*/
- (BOOL) isRegistered;
/**
* Set charset of QFont to this.
* Should be used instead of -[QFont setCharSet]
*
* @param fnt Font we want set charset of
* @return The font after setting the charset
*/
- (QFont *) setQFont: (QFont *) fnt;
/**
* Get QT's id of charset.
* Qt has id defined only for ISO-8859-* charsets, so their
* charset functions should not be used
*
* @return The Qt font charset id
*/
- (int) qtCharset;
/**
* Get nuber of bits needed to represent a character.
* As for now only 8-bit characters are supported well
*
* @return Number of bits per character
*/
- (int) bits;
/**
* check if character is printable in selected charset
*
* @param chr Character to check
* @return YES if it is printable
*/
- (BOOL) printable: (int) chr;
/**
* Gets X charset identifier (last two fields of X font name)
*
* @return string representing X charset name
*/
- (NSString *) xCharset;
@end
@class KCharsetConversionResult;
/**
* Class to convert character sets
*
* This class implements converting strings between charsets and encodings.
*
* Derived from the C++ header kcharsets.h
* by Jacek Konieczny <jacus@zeus.polsl.gliwice.pl>
* @short KDE charset support class
*/
@interface KCharsetConverter : NSObject
/**
* Conversion flags
*
* They can be use to specify how some characters can be converted.
*
* INPUT_AMP_SEQUENCES - convert amp-sequences on input to coresponding characters
* OUTPUT_AMP_SEQUENCES - convert unknown characters to amp-sequences
* AMP_SEQUENCES - two above together
* UNKNOWN_TO_ASCII - convert unknown characters to ASCII equivalents (not implemented yet)
* UNKNOWN_TO_QUESTION_MARKS - convert unknown characters to '?'
*/
#define INPUT_AMP_SEQUENCES 1
#define OUTPUT_AMP_SEQUENCES 2
#define AMP_SEQUENCES INPUT_AMP_SEQUENCES|OUTPUT_AMP_SEQUENCES
#define UNKNOWN_TO_ASCII 4
#define UNKNOWN_TO_QUESTION_MARKS 0
/**
* Initializer. Start conversion to displayable charset
*
* @param inputCharset source charset
* @param flags conversion flags.
*
*/
- initFromCharset: (KCharset *) inputCharset flags: (int) flags;
/**
* Initializer. Start conversion between two charsets
*
* @param inputCharset source charset
* @param outputCharset destination charset
* @param flags conversion flags. @ref KCharsetConverter
*
*/
- initFromCharset: (KCharset *) inputCharset outputCharset: (KCharset *) outputCharset flags: (int) flags;
- (void) dealloc;
/**
* Did initializer succeed.
*
* @return YES if conversion can be made, FALSE if wrong
* arguments were given to initializer
*/
- (BOOL) ok;
/**
* String conversion routine
*
* Convert string between charsets
*
* @param str string to convert
* @return converted string with charset info
*
*/
- (KCharsetConversionResult *) convertFromString: (NSString *) str;
/**
* String conversion routine for multiple charsets
*
* Convert string between charsets
*
* @param str string to convert
* @return converted string divided into chunks of the same charsets
*
*/
- (NSArray *) multipleConvert: (NSString *) str;
/**
* Charset of converted strings
*
* @return charset of strings converted using @ref convert(const char *)
*/
- (NSString *) outputCharset;
/**
* Unicode to displayable character conversion
*
* Currently works only for characters in output charset
*
* @param code Unicode represantation of character
*
*/
- (KCharsetConversionResult *) convertFromCode: (unsigned int) code;
/**
* Character tag to displayable character conversion
*
* Useful for converting HTML entities, but not only
* Currently it works only for characters in output charset
*
* @param tag character tag or whole amp-sequence
*
*/
- (KCharsetConversionResult *) convertTag: (NSString *) tag;
- (KCharsetConversionResult *) convertTag: (NSString *) tag length: (int *) l;
@end
/**
* KDE Multiple charset support
*
* This class gives information about available charsets
* and converts charsets' names to Qt identifiers
*
* Derived from the C++ header kcharsets.h by
* Jacek Konieczny <jacus@zeus.polsl.gliwice.pl>
* @short KDE charset support class
*/
@interface KCharsets : NSObject
/**
* Initialize a KCharsets class
*/
- init;
- (void) dealloc;
/**
* Returns default charset
*
* This charset is one in whitch keyboard input is made
*
* @return default charset
* @see #-setDefault:
*/
- (KCharset *) defaultCh;
/**
* Sets default charset
*
* @param ch charset to be set as default
*/
- (BOOL) setDefault: (KCharset *) ch;
/**
* Returns available charsets list
*
* Available charsets are these, between which we can make conversions
*
* @return list of available charsets
* @see #-isAvailable:
*/
- (NSArray *) available;
/**
* Returns displayable charsets list for given font family
*
* display charsets are these, which can be set to QFont.
* There is workaround for 8-bit charsets not directly
* supported by Qt 1.31
*
* @param face Font family we want display text in
* @return list of displayable charsets
* @see #-isDisplayable:
*/
- (NSArray *) displayable: (NSString *) face;
/**
* Returns displayable charsets list
*
* display charsets are these, which can be set to QFont.
* There is workaround for 8-bit charsets not directly
* supported by Qt 1.31
*
* @param face Font family we want display text in
* @return list of displayable charsets
* @see #-isDisplayable:
*/
- (NSArray *) displayable;
/**
* Returns registered charsets list
*
* Only registered charsets can be legally used in mail and news
* messages and on WWW pages.
*
* @return list of registered charsets
* @see #-isRegistered:
*/
- (NSArray *) registered;
/**
* Is the charset available
*
* @param charset charset name
* @return YES if the charset is available
* @see #-available
*/
- (BOOL) isAvailable: (KCharset *) charset;
/**
* Is the charset displayable in given font family
*
* @param face font family name
* @param charset charset name
* @return YES if the charset is displayable
* @see #-displayable
*/
- (BOOL) isDisplayable: (KCharset *) charset face: (NSString *) face;
/**
* Is the charset displayable in given font family
*
* @param charset charset name
* @return YES if the charset is displayable
* @see #-displayable
*/
- (BOOL) isDisplayable: (KCharset *) charset;
/**
* Is the charset registered
*
* @param charset charset name
* @return YES if the charset is registered
* @see #-registered
*/
- (BOOL) isRegistered: (KCharset *) charset;
/**
* Retruns data bits needed to represent character in charset
*
* For UTF7 and UTF8 charsets it returns 8, but some charsets
* may need more bits.
*
* @param charset charset name
* @return bits count
*/
- (int) bits: (KCharset *) charset;
/**
* Returns Qt charset identifier
*
* @param charset charset name
* @return Qt charset identifier
*/
- (QFont *) qtCharset: (KCharset *) charset;
/**
* Returns Qt charset identifier for default font
*
* @return Qt charset identifier
*/
- (QFont *) qtCharset;
/**
* Sets QFont object to given charsets
*
* This function can change font face when necessary.
* It is a workaround for Qt not supporting some charsets
*
* @param fnt font object
* @param charset charset name
* @return the same font object
*/
- (QFont *) setQFont: (QFont *) fnt charset: (KCharset *) charset;
/**
* Sets QFont object to default charsets
*
* This function can change font face when necessary.
* It is a workaround for Qt not supporting some charsets
*
* @param fnt font object
* @return the same font object
*/
- (QFont *) setQFont: (QFont *) fnt;
/**
* Returns charset name of given charset identifier
*
* @param qtcharset Qt charset identifier
* @return charset name
*/
- (NSString *) nameFromQtCharset: (int) qtcharset;
/**
* Returns charset of given charset identifier
*
* @param qtcharset Qt charset identifier
* @return charset object
*/
- (KCharset *) charsetFromQtCharset: (int) qtcharset;
/**
* Returns charset name of given QFont object
*
* @param font QFont object
* @return charset name
*/
- (NSString *) nameFromFont: (QFont *) font;
/**
* Returns charset of given QFont object
*
* @param font QFont object
* @return charset object
*/
- (KCharset *) charsetFromFont: (QFont *) font;
/**
* Returns charset of given X name object
*
* @param xName X charset name
* @return charset object
*/
- (KCharset *) charsetFromX: (NSString *) xName;
/**
* Unicode to displayable character conversion
*
* Currently works only for characters in output charset
*
* @param code Unicode represantation of character
*
*/
- (KCharsetConversionResult *) convert: (unsigned int) code;
/**
* Character tag to displayable character conversion
*
* Useful for converting HTML entities, but not only
* Currently it works only for characters in output charset
*
* @param tag character tag or whole amp-sequence
*
*/
- (KCharsetConversionResult *) convertTag: (NSString *) tag;
- (KCharsetConversionResult *) convertTag: (NSString *) tag length: (int *) len;
- (KCharset *) defaultCharset;
@end
#endif
Documentation generated by duke@tipitina on Sat May 6 11:42:52 EDT 2000