OpenTTD Source: src/core/utf8.cpp File Reference

OpenTTD Source 15.3

Functions
utf8.cpp File Reference

Handling of UTF-8 encoded data. More...

`#include "../stdafx.h"`
`#include "utf8.hpp"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Functions
std::pair< char[4], size_t > | EncodeUtf8 (char32_t c)
| Encode a character to UTF-8.
std::pair< size_t, char32_t > | DecodeUtf8 (std::string_view buf)
| Decode a character from UTF-8.

## Detailed Description

Handling of UTF-8 encoded data.

Definition in file utf8.cpp.

## Function Documentation

## ◆ DecodeUtf8()

std::pair< size_t, char32_t > DecodeUtf8 | ( | std::string_view | buf | ) |

Decode a character from UTF-8.

Parameters

  buf | Binary data.

Returns
  Length and character. Length is zero, if the input data is invalid.

Definition at line 48 of file utf8.cpp.

References GB(), and HasBit().

Referenced by GlobalVarChangeInfo(), StringConsumer::PeekUtf8(), and VideoDriver_SDL_Base::PollEvent().

## ◆ EncodeUtf8()

std::pair< char[4], size_t > EncodeUtf8 | ( | char32_t | c | ) |

Encode a character to UTF-8.

Parameters

  c | Character

Returns
  Binary data and length. Length is zero, if "c" is out of range.

Definition at line 21 of file utf8.cpp.

References GB().

Referenced by StringConsumer::FindUtf8(), Textbuf::InsertChar(), StringConsumer::PeekUntilUtf8(), BaseStringBuilder::PutUtf8(), StringConsumer::ReadUntilUtf8(), and StringConsumer::SkipUntilUtf8().