Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content

This is a preview of the documentation for the next version of Cahute.

It may describe features that are not available in the latest release.

Cahute 0.6
Logo
Cahute 0.6
  • Installation guides
    • Installing Cahute on Linux distributions
    • Installing Cahute on macOS / OS X
    • Installing Cahute on Microsoft Windows
    • Installing Cahute on AmigaOS
  • Build from source guides
    • Building Cahute for Linux distributions
    • Building Cahute for macOS / OS X
    • Building Cahute for Microsoft Windows
    • Building Cahute for AmigaOS
  • Contribution guides
    • Contributing to Cahute
    • Reporting a bug or vulnerability
    • Requesting a feature
    • Packaging Cahute
    • Creating a merge request
  • Command line user guides
    • Getting information regarding a calculator
    • Sending a file to a calculator’s storage memory
    • Getting a file from the calculator’s storage memory
    • Displaying the screen from a calculator
  • Developer guides
    • Building with the Cahute library
    • Using device detection
      • Listing calculators connected by USB
      • Listing available serial ports
    • Using links
      • Opening a link to a calculator connected by USB
      • Opening a generic link to a calculator connected by serial
    • Reading and writing files
      • Guessing the type of a file
    • Using text conversion utilities
      • Converting text from an encoding to another
  • Miscellaneous guides
    • Getting started with Cahute in Visual Studio
    • Capturing USB communications on Windows using Wireshark
  • Data formats
    • Number formats
    • Picture formats
    • Text encodings
    • File formats
      • fx-CG add-ins
      • fx-9860G add-ins
      • Calculator Text Format (CTF)
      • CASIOLINK archives
      • casrc configuration file
      • Catalog files (CAT)
      • e-Activity files
      • eAct Maker file
      • fx-CG f-key files
      • fx-9860G f-key files
      • FX Program (FXP)
      • GraphCard file format
      • fx-CG language files
      • fx-9860G language files
      • Main memory archives
      • fx-CG picture
      • fx-CP picture
  • Communication protocols
    • Rationales behind the communication protocols
    • Transport medium and protocols
    • USB detection for CASIO calculators
    • CASIOLINK protocols – Serial protocols used by pre fx-9860G calculators
    • CAS40 protocol – Serial protocol used by pre-1996 calculators
      • CAS40 packet format
      • CAS40 data types
      • CAS40 flows
    • CAS50 protocol – Serial protocol used by calculators from 1996 to 2004
      • CAS50 packet format
      • CAS50 data types
      • CAS50 flows
    • CAS100 protocol – Serial protocol used by AFX / Graph 100
      • CAS100 packet format
      • CAS100 data types
      • CAS100 flows
    • CAS300 – Serial and USB protocol used by Classpad 300 / 330 (+)
      • CAS300 packet format
      • CAS300 commands
      • CAS300 flows
    • Protocol 7.00 – Serial and USB protocol used by post fx-9860G calculators
      • Specific formats for Protocol 7.00
      • Protocol 7.00 packet format
      • Protocol 7.00 communication flows
      • Known Protocol 7.00 commands by CASIO
      • Known Protocol 7.00 command extensions in fxRemote
      • Protocol 7.00 use cases
      • Known hardware identifiers for Protocol 7.00
    • Protocol 7.00 Screenstreaming – fx-9860G and fx-CG screenstreaming
      • Protocol 7.00 Screenstreaming packet format
      • Protocol 7.00 Screenstreaming communication flows
    • USB Mass Storage (UMS)
  • Cahute features
    • System compatibility
    • Contexts
    • Links and mediums
    • Files
    • Main memory data
    • Logging facilities
  • Cahute internals
    • Internal compatibility utilities
    • Links and medium internals
    • File internals
    • Characters, encodings and conversions
  • Command line reference
    • CaS command-line reference
    • p7 command line reference
    • p7os command line reference
    • p7screen command line reference
    • xfer9860 command line reference
  • Header reference
    • <cahute.h> – Main header for Cahute
      • <cahute/cdefs.h> – Basic definitions for Cahute
      • <cahute/config.h> – Cahute configuration details
      • <cahute/context.h> – Context management for Cahute
      • <cahute/data.h> – Calculator data resource and methods for Cahute
      • <cahute/detection.h> – Device detection for Cahute
      • <cahute/error.h> – Error definitions for Cahute
      • <cahute/file.h> – File related utilities for Cahute
      • <cahute/link.h> – Calculator link resource and methods for Cahute
      • <cahute/logging.h> – Logging control for Cahute
      • <cahute/path.h> – Path related utilities for Cahute
      • <cahute/picture.h> – Picture format related utilities for Cahute
      • <cahute/text.h> – Text encoding related utilities for Cahute
  • CMake setting reference
  • Project management
    • Project governance
    • Git and release versioning
    • Community feedback
    • Contribution style
    • Coding style
Back to top

<cahute/text.h> – Text encoding related utilities for Cahute¶

Macro definitions¶

CAHUTE_TEXT_ENCODING_* are constants representing how a given picture’s data is encoded.

CAHUTE_TEXT_ENCODING_LEGACY_8¶

Constant representing the Variable width encoding with the legacy character table.

CAHUTE_TEXT_ENCODING_LEGACY_16_HOST¶

Constant representing the Fixed-width encoding with the legacy character table, and host endianness.

CAHUTE_TEXT_ENCODING_LEGACY_16_BE¶

Constant representing the Fixed-width encoding with the legacy character table, and big endian.

CAHUTE_TEXT_ENCODING_LEGACY_16_LE¶

Constant representing the Fixed-width encoding with the legacy character table, and little endian.

CAHUTE_TEXT_ENCODING_9860_8¶

Constant representing the Variable width encoding with the fx-9860G character table.

CAHUTE_TEXT_ENCODING_9860_16_HOST¶

Constant representing the Fixed-width encoding with the fx-9860G character table, and host endianness.

CAHUTE_TEXT_ENCODING_9860_16_BE¶

Constant representing the Fixed-width encoding with the fx-9860G character table, and big endian.

CAHUTE_TEXT_ENCODING_9860_16_LE¶

Constant representing the Fixed-width encoding with the fx-9860G character table, and little endian.

CAHUTE_TEXT_ENCODING_CAT¶

Constant representing the CAT data encoding.

CAHUTE_TEXT_ENCODING_CTF¶

Constant representing the CTF data encoding.

CAHUTE_TEXT_ENCODING_UTF32_HOST¶

Constant representing the UTF-32 encoding, with host endianness.

CAHUTE_TEXT_ENCODING_UTF32_BE¶

Constant representing the UTF-32 encoding, with big endian.

CAHUTE_TEXT_ENCODING_UTF32_LE¶

Constant representing the UTF-32 encoding, with little endian.

CAHUTE_TEXT_ENCODING_UTF8¶

Constant representing the UTF-8 encoding.

Function declarations¶

int cahute_convert_text(cahute_context *context, void **bufp, size_t *buf_sizep, void const **datap, size_t *data_sizep, int dest_encoding, int source_encoding)¶

Convert text from one encoding to another.

Note

When CAHUTE_TEXT_ENCODING_UTF32_HOST, CAHUTE_TEXT_ENCODING_UTF32_BE, CAHUTE_TEXT_ENCODING_UTF32_LE or CAHUTE_TEXT_ENCODING_UTF8 is used as the destination encoding, Normalization Form C (NFC) is employed; see Unicode Normalization Forms for more information.

Errors you can expect from this function are the following:

CAHUTE_OK

The conversion has finished successfully, and there is no more bytes in the input buffer to read.

CAHUTE_ERROR_TERMINATED

A sentinel has been found, and the conversion has been interrupted.

Note

If this error is raised, *datap is set to after the sentinel, and *data_sizep is set accordingly.

This is useful in case you have multiple text blobs placed back-to-back.

CAHUTE_ERROR_SIZE

The destination buffer had insufficient space, and the procedure was interrupted.

CAHUTE_ERROR_TRUNC

The source data had an incomplete sequence, and the procedure was interrupted.

CAHUTE_ERROR_INVALID

The source data contained an unknown or invalid sequence, and the procedure was interrupted.

CAHUTE_ERROR_INCOMPAT

The source data contained a sequence that could not be translated to the destination encoding.

At the end of its process, this function updates *bufp, *buf_sizep, *datap and *data_sizep to the final state of the function, even in case of error, so that:

  • You can determine how much of the destination buffer was filled, by substracting the final buffer size to the original buffer size.

  • In case of CAHUTE_ERROR_SIZE, you can get the place at which to get the leftover bytes in the source data.

  • In case of CAHUTE_ERROR_TRUNC, you can get the place at which to get the leftover bytes in the source data to complete with additional data for the next conversion.

  • In case of CAHUTE_ERROR_INVALID or CAHUTE_ERROR_INCOMPAT, you can get the place of the problematic input sequence.

Currently supported conversions are the following:

Src. ⯈
▼ Dst.

LEGACY_*

9860_*

CAT

CTF

UTF*

LEGACY_*

x

x

9860_*

x

x

CAT

CTF

UTF*

x

x

x

For specific guides on how to use this function, see Converting text from an encoding to another.

Parameters:
  • context – Context in which to run the function.

  • bufp – Pointer to the destination buffer pointer.

  • buf_sizep – Pointer to the destination buffer size.

  • datap – Pointer to the source data pointer.

  • data_sizep – Pointer to the source data size.

  • dest_encoding – Destination encoding.

  • source_encoding – Source encoding.

Returns:

Error, or 0 if the operation was successful.

int cahute_convert_to_utf8(cahute_context *context, char *buf, size_t buf_size, void const *data, size_t data_size, int encoding)¶

Convert the provided data to UTF-8, and place a terminating NUL character.

This is a utility that calls cahute_convert_text(), for simple scripts using the Cahute library.

Parameters:
  • context – Context in which to run the function.

  • buf – Destination buffer.

  • buf_size – Destination buffer size.

  • data – Source data.

  • data_size – Size of the source data.

  • encoding – Encoding of the source data.

Returns:

Error, or 0 if the operation was successful.

Next
CMake setting reference
Previous
<cahute/picture.h> – Picture format related utilities for Cahute
Copyright © 2024, Thomas Touhey
Made with Sphinx and @pradyunsg's Furo
On this page
  • <cahute/text.h> – Text encoding related utilities for Cahute
    • Macro definitions
    • Function declarations