Add UConverter to intl extension to match Zend
[hiphop-php.git] / src / idl / icu_ucnv.idl.php
blob42f36b9f33d9b0d68400505e629035a629a0ef1e
1 <?php
2 /**
3 * @nolint
4 */
5 DefinePreamble(<<<CPP
7 #include <runtime/base/zend/zend_collator.h>
9 // Avoid dragging in the icu namespace.
10 #ifndef U_USING_ICU_NAMESPACE
11 #define U_USING_ICU_NAMESPACE 0
12 #endif
14 #include <unicode/utypes.h>
15 #include <unicode/ucnv.h>
16 #include <unicode/ustring.h>
17 CPP
20 BeginClass(
21 array(
22 'name' => "UConverter",
23 'desc' => "ICU UConverter class",
24 'flags' => HasDocComment,
25 'footer' => <<<CPP
26 private:
27 static void throwFailure(UErrorCode error,
28 const char *fname,
29 intl_error &merror);
30 bool checkLimits(int64_t available, int64_t needed);
31 void appendToUTarget(Variant val, UConverterToUnicodeArgs *args);
32 void appendFromUTarget(Variant val, UConverterFromUnicodeArgs *args);
33 static void ucnvToUCallback(c_UConverter *objval,
34 UConverterToUnicodeArgs *args,
35 const char *codeUnits, int32_t length,
36 UConverterCallbackReason reason,
37 UErrorCode *pErrorCode);
38 static void ucnvFromUCallback(c_UConverter *objval,
39 UConverterFromUnicodeArgs *args,
40 const UChar *codeUnits, int32_t length,
41 UChar32 codePoint,
42 UConverterCallbackReason reason,
43 UErrorCode *pErrorCode);
44 static bool setEncoding(CStrRef encoding,
45 UConverter **pcnv,
46 intl_error &err);
47 static bool setSubstChars(String chars, UConverter *cnv, intl_error &err);
48 bool setCallback(UConverter *cnv);
49 Variant defaultCallback(int64 reason, VRefParam error);
50 static String doConvert(CStrRef str, UConverter *toCnv,
51 UConverter *fromCnv, intl_error &err);
52 public:
53 intl_error m_error;
54 UConverter *m_src;
55 UConverter *m_dest;
56 CPP
60 DefineConstant(array(
61 'name' => "REASON_UNASSIGNED",
62 'type' => Int64,
63 ));
65 DefineConstant(array(
66 'name' => "REASON_ILLEGAL",
67 'type' => Int64,
68 ));
70 DefineConstant(array(
71 'name' => "REASON_IRREGULAR",
72 'type' => Int64,
73 ));
75 DefineConstant(array(
76 'name' => "REASON_RESET",
77 'type' => Int64,
78 ));
80 DefineConstant(array(
81 'name' => "REASON_CLOSE",
82 'type' => Int64,
83 ));
85 DefineConstant(array(
86 'name' => "REASON_CLONE",
87 'type' => Int64,
88 ));
90 DefineConstant(array(
91 'name' => "UNSUPPORTED_CONVERTER",
92 'type' => Int64,
93 ));
95 DefineConstant(array(
96 'name' => "SBCS",
97 'type' => Int64,
98 ));
100 DefineConstant(array(
101 'name' => "DBCS",
102 'type' => Int64,
105 DefineConstant(array(
106 'name' => "MBCS",
107 'type' => Int64,
110 DefineConstant(array(
111 'name' => "LATIN_1",
112 'type' => Int64,
115 DefineConstant(array(
116 'name' => "UTF8",
117 'type' => Int64,
120 DefineConstant(array(
121 'name' => "UTF16_BigEndian",
122 'type' => Int64,
125 DefineConstant(array(
126 'name' => "UTF16_LittleEndian",
127 'type' => Int64,
130 DefineConstant(array(
131 'name' => "UTF32_BigEndian",
132 'type' => Int64,
135 DefineConstant(array(
136 'name' => "UTF32_LittleEndian",
137 'type' => Int64,
140 DefineConstant(array(
141 'name' => "EBCDIC_STATEFUL",
142 'type' => Int64,
145 DefineConstant(array(
146 'name' => "ISO_2022",
147 'type' => Int64,
150 DefineConstant(array(
151 'name' => "LMBCS_1",
152 'type' => Int64,
155 DefineConstant(array(
156 'name' => "LMBCS_2",
157 'type' => Int64,
160 DefineConstant(array(
161 'name' => "LMBCS_3",
162 'type' => Int64,
165 DefineConstant(array(
166 'name' => "LMBCS_4",
167 'type' => Int64,
170 DefineConstant(array(
171 'name' => "LMBCS_5",
172 'type' => Int64,
175 DefineConstant(array(
176 'name' => "LMBCS_6",
177 'type' => Int64,
180 DefineConstant(array(
181 'name' => "LMBCS_8",
182 'type' => Int64,
185 DefineConstant(array(
186 'name' => "LMBCS_11",
187 'type' => Int64,
190 DefineConstant(array(
191 'name' => "LMBCS_16",
192 'type' => Int64,
195 DefineConstant(array(
196 'name' => "LMBCS_17",
197 'type' => Int64,
200 DefineConstant(array(
201 'name' => "LMBCS_18",
202 'type' => Int64,
205 DefineConstant(array(
206 'name' => "LMBCS_19",
207 'type' => Int64,
210 DefineConstant(array(
211 'name' => "LMBCS_LAST",
212 'type' => Int64,
215 DefineConstant(array(
216 'name' => "HZ",
217 'type' => Int64,
220 DefineConstant(array(
221 'name' => "SCSU",
222 'type' => Int64,
225 DefineConstant(array(
226 'name' => "ISCII",
227 'type' => Int64,
230 DefineConstant(array(
231 'name' => "US_ASCII",
232 'type' => Int64,
235 DefineConstant(array(
236 'name' => "UTF7",
237 'type' => Int64,
240 DefineConstant(array(
241 'name' => "BOCU1",
242 'type' => Int64,
245 DefineConstant(array(
246 'name' => "UTF16",
247 'type' => Int64,
250 DefineConstant(array(
251 'name' => "UTF32",
252 'type' => Int64,
255 DefineConstant(array(
256 'name' => "CESU8",
257 'type' => Int64,
260 DefineConstant(array(
261 'name' => "IMAP_MAILBOX",
262 'type' => Int64,
265 DefineFunction(
266 array(
267 'name' => "__construct",
268 'desc' => "Object constructor",
269 'flags' => HasDocComment,
270 'args' => array(
271 array(
272 'name' => "toEncoding",
273 'type' => String,
274 'value' => "\"utf-8\"",
275 'desc' => "Target character encoding",
277 array(
278 'name' => "fromEncoding",
279 'type' => String,
280 'value' => "\"utf-8\"",
281 'desc' => "Source character encoding",
287 DefineFunction(
288 array(
289 'name' => "__destruct",
290 'desc' => "Object destructor",
291 'return' => array(
292 'type' => Variant,
297 /* Get/Set Source/Destination encodings */
299 DefineFunction(
300 array(
301 'name' => "getSourceEncoding",
302 'desc' => "Returns the name of the source encoding",
303 'flags' => HasDocComment,
304 'return' => array(
305 'type' => String,
306 'desc' => "Cannonical name of source encoding",
311 DefineFunction(
312 array(
313 'name' => "setSourceEncoding",
314 'desc' => "Changes the source encoding converter to the named encoding",
315 'flags' => HasDocComment,
316 'args' => array(
317 array(
318 'name' => 'encoding',
319 'type' => String,
320 'desc' => "Name of encoding to use",
326 DefineFunction(
327 array(
328 'name' => "getDestinationEncoding",
329 'desc' => "Returns the name of the destination encoding",
330 'flags' => HasDocComment,
331 'return' => array(
332 'type' => String,
333 'desc' => "Cannonical name of destination encoding",
338 DefineFunction(
339 array(
340 'name' => "setDestinationEncoding",
341 'desc' => "Changes the destination encoding converter to the named encoding",
342 'flags' => HasDocComment,
343 'args' => array(
344 array(
345 'name' => 'encoding',
346 'type' => String,
347 'desc' => "Name of encoding to use",
353 /* Get algorithmic types */
355 DefineFunction(
356 array(
357 'name' => "getSourceType",
358 'desc' => "Returns the source algorithmic encoding type (e.g. SBCS, DBCS, LATIN_1, UTF8, etc...)",
359 'flags' => HasDocComment,
360 'return' => array(
361 'type' => Int64,
362 'desc' => "Algorithmic encoding type",
367 DefineFunction(
368 array(
369 'name' => "getDestinationType",
370 'desc' => "Returns the destination algorithmic encoding type (e.g. SBCS, DBCS, LATIN_1, UTF8, etc...)",
371 'flags' => HasDocComment,
372 'return' => array(
373 'type' => Int64,
374 'desc' => "Algorithmic encoding type",
379 /* Basic character substitution */
381 DefineFunction(
382 array(
383 'name' => "getSubstChars",
384 'desc' => "Returns the current substitution character used for conversion failures",
385 'flags' => HasDocComment,
386 'return' => array(
387 'type' => String,
388 'desc' => "One or more codeunits representing a single codepoint",
393 DefineFunction(
394 array(
395 'name' => "setSubstChars",
396 'desc' => "Set the substitution character to use for conversion failures",
397 'flags' => HasDocComment,
398 'return' => array(
399 'type' => Boolean,
400 'desc' => "Whether or not setting substitution characters succeeded",
402 'args' => array(
403 array(
404 'name' => "chars",
405 'type' => String,
406 'desc' => "One or more codeunits representing a codepoint",
412 /* Standard callbacks */
414 DefineFunction(
415 array(
416 'name' => "fromUCallback",
417 'desc' => "Issued by the object when converting to the target encoding",
418 'flags' => HasDocComment,
419 'return' => array(
420 'type' => Variant,
421 'desc' => "Substitution codeunits for illegal/irregular/unassigned codepoints",
423 'args' => array(
424 array(
425 'name' => "reason",
426 'type' => Int64,
427 'desc' => "Event which caused the callback",
429 array(
430 'name' => "source",
431 'type' => Int64Vec,
432 'desc' => "Contextual codepoints from the string being converted",
434 array(
435 'name' => "codepoint",
436 'type' => Int64,
437 'desc' => "The specific codepoint in question",
439 array(
440 'name' => "error",
441 'type' => Variant,
442 'ref' => true,
443 'desc' => "Reference param, error condition on the way in, should be U_ZERO_ERROR on the way out",
449 DefineFunction(
450 array(
451 'name' => "toUCallback",
452 'desc' => "Issued by the object when converting from the source encoding",
453 'flags' => HasDocComment,
454 'return' => array(
455 'type' => Variant,
456 'desc' => "Substitution codepoints for illegal/irregular/unassigned codeunits",
458 'args' => array(
459 array(
460 'name' => "reason",
461 'type' => Int64,
462 'desc' => "Event which caused the callback",
464 array(
465 'name' => "source",
466 'type' => String,
467 'desc' => "Contextual codeunits from the string being converted",
469 array(
470 'name' => "codeunits",
471 'type' => String,
472 'desc' => "The specific codeunits in question",
474 array(
475 'name' => "error",
476 'type' => Variant,
477 'ref' => true,
478 'desc' => "Reference param, error condition on the way in, should be U_ZERO_ERROR on the way out",
484 /* Primary converter functions */
486 DefineFunction(
487 array(
488 'name' => "convert",
489 'desc' => "Convert a string between the source/destination encodings",
490 'flags' => HasDocComment,
491 'return' => array(
492 'type' => Variant,
493 'desc' => "Transcoded string",
495 'args' => array(
496 array(
497 'name' => "str",
498 'type' => String,
499 'desc' => "String to be transcoded",
501 array(
502 'name' => "reverse",
503 'type' => Boolean,
504 'value' => "false",
505 'desc' => "Convert from destination to source encodings instead",
511 DefineFunction(
512 array(
513 'name' => "transcode",
514 'desc' => "Convert a string between two encodings",
515 'flags' => HasDocComment|IsStatic,
516 'return' => array(
517 'type' => Variant,
518 'desc' => "Transcoded string",
520 'args' => array(
521 array(
522 'name' => "str",
523 'type' => String,
524 'desc' => "String to be transcoded",
526 array(
527 'name' => "toEncoding",
528 'type' => String,
529 'desc' => "Source encoding",
531 array(
532 'name' => "fromEncoding",
533 'type' => String,
534 'desc' => "Destination encoding",
536 array(
537 'name' => "options",
538 'type' => StringMap,
539 'value' => "null_variant",
540 'desc' => "Optional configuration for converters",
546 /* ext/intl style error handlers */
548 DefineFunction(
549 array(
550 'name' => "getErrorCode",
551 'desc' => "Last UErrorCode associated with this converter",
552 'flags' => HasDocComment,
553 'return' => array(
554 'type' => Int64,
555 'desc' => "UErrorCode U_* value",
560 DefineFunction(
561 array(
562 'name' => "getErrorMessage",
563 'desc' => "Last error message associated with this converter",
564 'flags' => HasDocComment,
565 'return' => array(
566 'type' => String,
567 'desc' => "Descriptive error message",
572 /* Ennumerators and lookups */
574 DefineFunction(
575 array(
576 'name' => "reasonText",
577 'desc' => "Name of REASON_* constant",
578 'flags' => HasDocComment|IsStatic,
579 'return' => array(
580 'type' => String,
581 'desc' => "Printable REASON_* constant name",
583 'args' => array(
584 array(
585 'name' => "reason",
586 'type' => Int64,
587 'desc' => "REASON_* constant",
593 DefineFunction(
594 array(
595 'name' => "getAvailable",
596 'desc' => "Returns list of available encodings",
597 'flags' => HasDocComment|IsStatic,
598 'return' => array(
599 'type' => StringVec,
600 'desc' => "Available encodings",
605 DefineFunction(
606 array(
607 'name' => "getAliases",
608 'desc' => "Returns valid aliases of the named encoding",
609 'flags' => HasDocComment|IsStatic,
610 'return' => array(
611 'type' => StringVec,
612 'desc' => "Valid aliases of the named encoding",
614 'args' => array(
615 array(
616 'name' => "encoding",
617 'type' => String,
618 'desc' => "Encoding to get aliases of",
624 DefineFunction(
625 array(
626 'name' => "getStandards",
627 'desc' => "Returns list supported standards",
628 'flags' => HasDocComment|IsStatic,
629 'return' => array(
630 'type' => StringVec,
631 'desc' => "Available standards",
636 EndClass();