| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ |
| 6 #define PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_module.h" | 8 #include "ppapi/c/pp_module.h" |
| 9 #include "ppapi/c/pp_stdint.h" | 9 #include "ppapi/c/pp_stdint.h" |
| 10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
| 11 | 11 |
| 12 #define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.1" | 12 #define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.2" |
| 13 | 13 |
| 14 // Specifies the error behavior for the character set conversion functions. | 14 // Specifies the error behavior for the character set conversion functions. |
| 15 // This will affect two cases: where the input is not encoded correctly, and | 15 // This will affect two cases: where the input is not encoded correctly, and |
| 16 // when the requested character can not be converted to the destination | 16 // when the requested character can not be converted to the destination |
| 17 // character set. | 17 // character set. |
| 18 enum PP_CharSet_ConversionError { | 18 enum PP_CharSet_ConversionError { |
| 19 // Causes the entire conversion to fail if an error is encountered. The | 19 // Causes the entire conversion to fail if an error is encountered. The |
| 20 // conversion function will return NULL. | 20 // conversion function will return NULL. |
| 21 PP_CHARSET_CONVERSIONERROR_FAIL, | 21 PP_CHARSET_CONVERSIONERROR_FAIL, |
| 22 | 22 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 // terminating NULL, will be placed into *output_length. When there is no | 43 // terminating NULL, will be placed into *output_length. When there is no |
| 44 // error, the result will always be non-NULL, even if the output is 0-length. | 44 // error, the result will always be non-NULL, even if the output is 0-length. |
| 45 // In this case, it will only contain the terminator. You must still call | 45 // In this case, it will only contain the terminator. You must still call |
| 46 // MemFree any time the return value is non-NULL. | 46 // MemFree any time the return value is non-NULL. |
| 47 // | 47 // |
| 48 // This function will return NULL if there was an error converting the string | 48 // This function will return NULL if there was an error converting the string |
| 49 // and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output character | 49 // and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output character |
| 50 // set was unknown. | 50 // set was unknown. |
| 51 char* (*UTF16ToCharSet)(const uint16_t* utf16, uint32_t utf16_len, | 51 char* (*UTF16ToCharSet)(const uint16_t* utf16, uint32_t utf16_len, |
| 52 const char* output_char_set, | 52 const char* output_char_set, |
| 53 PP_CharSet_ConversionError on_error, | 53 enum PP_CharSet_ConversionError on_error, |
| 54 uint32_t* output_length); | 54 uint32_t* output_length); |
| 55 | 55 |
| 56 // Same as UTF16ToCharSet except converts in the other direction. The input | 56 // Same as UTF16ToCharSet except converts in the other direction. The input |
| 57 // is in the given charset, and the |input_len| is the number of bytes in | 57 // is in the given charset, and the |input_len| is the number of bytes in |
| 58 // the |input| string. |*output_length| is the number of 16-bit values in | 58 // the |input| string. |*output_length| is the number of 16-bit values in |
| 59 // the output not counting the terminating NULL. | 59 // the output not counting the terminating NULL. |
| 60 // | 60 // |
| 61 // Since UTF16 can represent every Unicode character, the only time the | 61 // Since UTF16 can represent every Unicode character, the only time the |
| 62 // replacement character will be used is if the encoding in the input string | 62 // replacement character will be used is if the encoding in the input string |
| 63 // is incorrect. | 63 // is incorrect. |
| 64 uint16_t* (*CharSetToUTF16)(const char* input, uint32_t input_len, | 64 uint16_t* (*CharSetToUTF16)(const char* input, uint32_t input_len, |
| 65 const char* input_char_set, | 65 const char* input_char_set, |
| 66 PP_CharSet_ConversionError on_error, | 66 enum PP_CharSet_ConversionError on_error, |
| 67 uint32_t* output_length); | 67 uint32_t* output_length); |
| 68 | 68 |
| 69 // Returns a string var representing the current multi-byte character set of | 69 // Returns a string var representing the current multi-byte character set of |
| 70 // the current system. | 70 // the current system. |
| 71 // | 71 // |
| 72 // WARNING: You really shouldn't be using this function unless you're dealing | 72 // WARNING: You really shouldn't be using this function unless you're dealing |
| 73 // with legacy data. You should be using UTF-8 or UTF-16 and you don't have | 73 // with legacy data. You should be using UTF-8 or UTF-16 and you don't have |
| 74 // to worry about the character sets. | 74 // to worry about the character sets. |
| 75 PP_Var (*GetDefaultCharSet)(PP_Module module); | 75 struct PP_Var (*GetDefaultCharSet)(PP_Module module); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 #endif // PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ | 78 #endif // PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ |
| OLD | NEW |