home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / j2sdk / files / linux / j2sdklin.bin / jdk1.3.1 / include-old / javaString.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-06  |  2.1 KB  |  83 lines

  1. /*
  2.  * @(#)javaString.h    1.23 00/02/02
  3.  *
  4.  * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the proprietary information of Sun Microsystems, Inc.  
  7.  * Use is subject to license terms.
  8.  * 
  9.  */
  10.  
  11. /*
  12.  * Java string utilities
  13.  */
  14.  
  15. #ifndef _JAVASOFT_JAVASTRING_H_
  16. #define _JAVASOFT_JAVASTRING_H_
  17.  
  18. #include "oobj.h"
  19.  
  20. #include "java_lang_String.h"
  21.  
  22.  
  23. /*
  24.  * Return the length of the String object.
  25.  */
  26. int javaStringLength(Hjava_lang_String *);
  27.  
  28.  
  29. /*
  30.  * Create and return a new Java String object, initialized from the C string.
  31.  */
  32. Hjava_lang_String *makeJavaString(char *, int);
  33.  
  34. /*
  35.  * Create a new C string initialized from the specified Java string,
  36.  * and return a pointer to it.
  37.  * For makeCString, temporary storage is allocated and released automatically
  38.  * when all references to the returned value are eliminated. WARNING: You 
  39.  * must keep this pointer in a variable to prevent the storage from getting
  40.  * garbage collected.
  41.  * For allocCString, a "malloc" is used to get the storage; the caller is
  42.  * responsible for "free"ing the pointer that is returned.
  43.  * 
  44.  */
  45. char *makeCString(Hjava_lang_String *s);
  46. char *allocCString(Hjava_lang_String *s);
  47.  
  48. /*
  49.  * Get the characters of the String object into a C string buffer.
  50.  * No allocation occurs. Assumes that len is the size of the buffer.
  51.  * The C string's address is returned.
  52.  */
  53. char *javaString2CString(Hjava_lang_String *, char *, int);
  54.  
  55. /*
  56.  * convert Java String to platform encoding string.
  57.  */
  58. char *makePlatformCString(Hjava_lang_String *);
  59.  
  60. /*
  61.  * convert platform encoding string to Java String.
  62.  */
  63. Hjava_lang_String *makeJavaStringFromPlatformCString(char *, int);
  64.  
  65. /*
  66.  * Fill buf with unicode representation of hstr, upto buflen chars.
  67.  * The UTF string will be NUL-terminated.
  68.  *
  69.  * If both buf and buflen are 0, malloc an appropriately sized
  70.  * buffer for the result.
  71.  *
  72.  * Return result buffer.
  73.  */
  74. char *javaString2UTF(HString *, char *, int);
  75.  
  76. /*
  77.  * Create a Java String whose characters are initialized from
  78.  * the supplied NUL-terminated UTF string.
  79.  */
  80. HString *makeJavaStringUTF(char *);
  81.  
  82. #endif /* !_JAVASOFT_JAVASTRING_H_ */
  83.