SourceForge.net Logo
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

EkStrings.h File Reference

Functions to support miscellaneous <SPmtString> manipulation. More...

#include <string>
#include "ptstring.h"
#include "EkCompiler.h"

Include dependency graph for EkStrings.h:

This graph shows which files directly or indirectly include this file:

Defines

#define EK_L(x)   x
#define EK_STR2WIDE(str)   str
#define EK_WIDE2STR(str)   str

Typedefs

typedef ptstring< char > SPmtString
typedef SPmtString EkString

Functions

void EK_DECL EkPutWString (ostream &stream, const wstring &ws)
 Writes a wide string to an output stream. More...

void EK_DECL EkGetWString (istream &stream, wstring &ws)
 Reads a wide string from an input stream. More...

wstring EK_DECL EkAToW (const SPmtString &str)
 Converts an ASCII string to a wide string. More...

SPmtString EK_DECL EkWToA (const wstring &ws, char f='?', const char *e=0)
 Converts a unicode string to ASCII. More...


Detailed Description

Functions to support miscellaneous <SPmtString> manipulation.

These functions support for miscellaneous <SPmtString> functions, such as conversion of wide char strings to ASCII strings, and vice-versa. Use the EKL macro to control casting of <SPmtString> literals i.e., EKL("literal") under UNICODE will produce L"literal"

For some inexplicable reason, declaring ostream "<<" or istream ">>" operators as dllexport does not work. The code compiles, but these operators do not show up in the list of exports for the DLL. The solution is to implement "Put" and "Get" functions which the inlined operators then call. The "Put" and "Get" functions cannot return the stream. If they do, then the exporting of them is also ignored.


Define Documentation

#define EK_L      x
 

#define EK_STR2WIDE str       str
 

#define EK_WIDE2STR str       str
 


Typedef Documentation

typedef SPmtString EkString
 

typedef ptstring<char> SPmtString
 


Function Documentation

wstring EK_DECL EkAToW const SPmtString   str
 

Converts an ASCII string to a wide string.

Parameters:
str  The handle to the ASCII string to be converted
Returns:
wstring The resulting wide string

void EK_DECL EkGetWString istream &    stream,
wstring &    ws
 

Reads a wide string from an input stream.

Parameters:
stream  The handle to the input stream
ws  The handle to the wide string to be read into

void EK_DECL EkPutWString ostream &    stream,
const wstring &    ws
 

Writes a wide string to an output stream.

Parameters:
stream  The handle to the output stream
ws  The handle to the wide string to be written out

SPmtString EK_DECL EkWToA const wstring &    ws,
char    f = '?',
const char *    e = 0
 

Converts a unicode string to ASCII.

Parameters:
str  The handle to the ASCII string to be converted
Returns:
wstring The resulting wide string
Converts a unicode string to ASCII using operating system dependent functions, which may depend on current locale settings.

By default, any character which cannot be converted from unicode to 8-bit ASCII will be replaced by '?'. If you'd like to use a different character for these conversion failures, pass it as the second argument.

If you don't want substitution characters used when a conversion error occurs, you may pass a null-character as the second argument ('\0'). In that case, if a conversion error occurs, the conversion procedure stops and EkWTOA returns the third argument to the function as a string.

Examples:

      EkWTOA (L"ABC")                           returns the string "ABC"
      EkWTOA (L"A\400C")                        returns the string "A?C"
      EkWTOA (L"A\400C",'.')            returns the string "A.C"
      EkWTOA (L"A\400C",'\0')           returns the string ""
      EkWTOA (L"A\400C",'\0',"DARN!") returns the string "DARN!"

Last Updated: March 12, 2003 (rlr)
Copyright © 2003 Eastman Kodak Company All Rights Reserved.