1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
6 /* From trusted/ppb_char_set_trusted.idl modified Wed Feb 8 16:34:25 2012. */
8 #ifndef PPAPI_C_TRUSTED_PPB_CHAR_SET_TRUSTED_H_
9 #define PPAPI_C_TRUSTED_PPB_CHAR_SET_TRUSTED_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_stdint.h"
15 #include "ppapi/c/pp_var.h"
17 #define PPB_CHARSET_TRUSTED_INTERFACE_1_0 "PPB_CharSet_Trusted;1.0"
18 #define PPB_CHARSET_TRUSTED_INTERFACE PPB_CHARSET_TRUSTED_INTERFACE_1_0
23 * This file defines the <code>PPB_CharSet_Trusted</code> interface.
33 * Causes the entire conversion to fail if an error is encountered. The
34 * conversion function will return NULL.
36 PP_CHARSET_TRUSTED_CONVERSIONERROR_FAIL
,
38 * Silently skips over errors. Unrepresentable characters and input encoding
39 * errors will be removed from the output.
41 PP_CHARSET_TRUSTED_CONVERSIONERROR_SKIP
,
43 * Replaces the error or unrepresentable character with a substitution
44 * character. When converting to a Unicode character set (UTF-8 or UTF-16) it
45 * will use the unicode "substitution character" U+FFFD. When converting to
46 * another character set, the character will be charset-specific. For many
47 * languages this will be the representation of the '?' character.
49 PP_CHARSET_TRUSTED_CONVERSIONERROR_SUBSTITUTE
50 } PP_CharSet_Trusted_ConversionError
;
51 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CharSet_Trusted_ConversionError
, 4);
57 * @addtogroup Interfaces
61 * The <code>PPB_CharSet_Trusted</code> interface provides functions for
62 * converting between character sets.
64 * This inteface is provided for trusted plugins only since in Native Client it
65 * would require an expensive out-of-process IPC call for each conversion,
66 * which makes performance unacceptable. Native Client plugins should include
67 * ICU or some other library if they need this feature.
69 struct PPB_CharSet_Trusted_1_0
{
71 * Converts the UTF-16 string pointed to by |*utf16| to an 8-bit string in
72 * the specified code page. |utf16_len| is measured in UTF-16 units, not
73 * bytes. This value may not be NULL.
75 * The given output buffer will be filled up to output_length bytes with the
76 * result. output_length will be updated with the number of bytes required
77 * for the given string. The output buffer may be null to just retrieve the
78 * required buffer length.
80 * This function will return PP_FALSE if there was an error converting the
81 * string and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output
82 * character set was unknown. Otherwise, it will return PP_TRUE.
84 PP_Bool (*UTF16ToCharSet
)(const uint16_t utf16
[],
86 const char* output_char_set
,
87 PP_CharSet_Trusted_ConversionError on_error
,
89 uint32_t* output_length
);
91 * Same as UTF16ToCharSet except converts in the other direction. The input
92 * is in the given charset, and the |input_len| is the number of bytes in
95 * Note that the output_utf16_length is measured in UTF-16 characters.
97 * Since UTF16 can represent every Unicode character, the only time the
98 * replacement character will be used is if the encoding in the input string
101 PP_Bool (*CharSetToUTF16
)(const char* input
,
103 const char* input_char_set
,
104 PP_CharSet_Trusted_ConversionError on_error
,
105 uint16_t* output_buffer
,
106 uint32_t* output_utf16_length
);
108 * Returns a string var representing the current multi-byte character set of
109 * the current system.
111 * WARNING: You really shouldn't be using this function unless you're dealing
112 * with legacy data. You should be using UTF-8 or UTF-16 and you don't have
113 * to worry about the character sets.
115 struct PP_Var (*GetDefaultCharSet
)(PP_Instance instance
);
118 typedef struct PPB_CharSet_Trusted_1_0 PPB_CharSet_Trusted
;
123 #endif /* PPAPI_C_TRUSTED_PPB_CHAR_SET_TRUSTED_H_ */