PCRE_UTF16_TO_HOST_BYTE_ORDER(3)

✨ PCRE_UTF16..._BYTE_ORDER ✨

okay bestie, so this is a page from the PCRE (Perl-compatible regular expressions) manual, section 3. it lives in the 16-bit library and nowhere else, so if you're on the 8-bit side of the house this one is not for you πŸ’…


🌸 SYNOPSIS 🌸

#include <pcre.h>

int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *output,
     PCRE_SPTR16 input, int length, int *host_byte_order,
     int keep_boms);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function, which β€” reminder β€” exists only in the 16-bit library, no cap, takes a UTF-16 string and converts it into the correct byte order for whatever host you're on right now. and the way it does that is by paying attention to any byte order marks (BOMs) chillin' inside the string πŸ‘‘

its arguments are giving very much:

  • output β€” pointer to the output buffer. and here's the cute part: it may be the same as input πŸ’–
  • input β€” pointer to the input buffer
  • length β€” the number of 16-bit units in the input, or negative for a zero-terminated string
  • host_byte_order β€” a NULL value, or a non-zero value pointed to, means "start in host byte order"
  • keep_boms β€” if non-zero, the BOMs get copied into the output string πŸŽ€

the result of the function is the number of 16-bit units placed into the output buffer, and that count includes the zero terminator if the string was zero-terminated. so like, do with that number what you will, bestie ✨

and if host_byte_order is not NULL, it gets set to indicate the byte order that is current at the end of the string. little update, for free 😌


okay and for the full lore: there is a complete description of the PCRE native API in the pcreapi page, and a description of the POSIX API in the pcreposix page. go read those, fr fr πŸ“š

πŸ‘‘ SEE ALSO πŸ‘‘

  • pcreapi β€” the complete description of the PCRE native API
  • pcreposix β€” the description of the POSIX API

that's the whole vibe, no notes 🫢 this page is from PCRE 8.30, dated 21 January 2012, and it's a Library Functions Manual moment. mwah. πŸ’‹