Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.8 KiB

  1. /*
  2. File: HITextUtils.h
  3. Contains: Text utilities provided by HIToolbox.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c)2002 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __HITEXTUTILS__
  11. #define __HITEXTUTILS__
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __COREFOUNDATION__
  16. #include <CoreFoundation.h>
  17. #endif
  18. #ifndef __TEXTCOMMON__
  19. #include <TextCommon.h>
  20. #endif
  21. #if PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if PRAGMA_IMPORT
  28. #pragma import on
  29. #endif
  30. /*
  31. * GetTextAndEncodingFromCFString()
  32. *
  33. * Summary:
  34. * Converts the contents of a CFString to the one- or two-byte
  35. * encoding that most accurately represents the original Unicode
  36. * characters in the string.
  37. *
  38. * Discussion:
  39. * Because the Macintosh toolbox has had, until Carbon, little
  40. * support for Unicode, you may often find that your applications
  41. * need to translate a CFString (containing Unicode characters) back
  42. * to a one- or two-byte encoding of the string in order to draw,
  43. * measure, or otherwise use the text in the string.
  44. * GetTextAndEncodingFromCFString is a utility that may be helpful
  45. * to do this, in some circumstances. The Carbon toolbox uses this
  46. * API itself when translating CFStrings to Pascal strings.
  47. * GetTextAndEncodingFromCFString attempts to convert the Unicode
  48. * characters in the string to the closest non-Unicode
  49. * representation of the string. For example, a string containing
  50. * only Unicode characters that are present in the MacRoman one-byte
  51. * encoding will be translated to MacRoman, and
  52. * kTextEncodingMacRoman will be returned as the encoding of the
  53. * text. A string containing Unicode characters that are present in
  54. * the MacJapanese two-byte encoding will be translated to
  55. * MacJapanese (Shift-JIS), and kTextEncodingMacJapanese will be
  56. * returned as the encoding of the text.
  57. * GetTextAndEncodingFromCFString is designed to be used for simple
  58. * strings which contain only text from a single language. It is not
  59. * designed to translate strings with multiple runs of text from
  60. * different languages, and will only return the first run of such a
  61. * string; for example, if you pass it a string containing a run of
  62. * Roman characters followed by a run of Japanese characters, it
  63. * will only return the Roman characters in the output buffer. For
  64. * more complex text translation, you should call the Unicode
  65. * converter directly (see ConvertFromUnicodeToTextRun, which
  66. * GetTextAndEncodingFromCFString uses internally).
  67. *
  68. * Parameters:
  69. *
  70. * inString:
  71. * The string to convert.
  72. *
  73. * outText:
  74. * The output buffer in which to place the converted text.
  75. *
  76. * inTextMaxLength:
  77. * The length in bytes of the input buffer.
  78. *
  79. * outTextLength:
  80. * On exit, contains the length in bytes of the text that was
  81. * placed into the output buffer.
  82. *
  83. * outEncoding:
  84. * On exit, contains the encoding of the text that was placed into
  85. * the output buffer.
  86. *
  87. * Availability:
  88. * Non-Carbon CFM: not available
  89. * CarbonLib: in CarbonLib 1.2.5 and later
  90. * Mac OS X: in version 10.0 and later
  91. */
  92. EXTERN_API( OSStatus )
  93. GetTextAndEncodingFromCFString(
  94. CFStringRef inString,
  95. BytePtr outText,
  96. ByteCount inTextMaxLength,
  97. ByteCount * outTextLength,
  98. TextEncoding * outEncoding); /* can be NULL */
  99. #ifdef PRAGMA_IMPORT_OFF
  100. #pragma import off
  101. #elif PRAGMA_IMPORT
  102. #pragma import reset
  103. #endif
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif /* __HITEXTUTILS__ */