RKCVTHAN(3)

πŸ’– RKCVTHAN β€” okay bestie, let's talk character conversion πŸ’–

So this is a page from the Library Functions Manual, and it's all about RkCvtHan and RkwCvtHan. Two icons, one job. Let's get into it. ✨


🌸 NAME 🌸

RkCvtHan, RkwCvtHan β€” these cuties convert double-width symbols, alphanumeric characters, hiragana, and katakana into single-width characters. That's the whole vibe. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <canna/RK.h>
int RkCvtHan(dst, maxdst, src, srclen)
unsigned char *dst;
int maxdst;
unsigned char *src;
int srclen;
int RkwCvtHan(dst, maxdst, src, srclen)
wchar_t *dst;
int maxdst;
wchar_t *src;
int srclen;

Like, look at them. So tidy. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so RkCvtHan takes the srclen bytes of your double-width symbol, alphanumeric, hiragana, and katakana data and converts them to single-width characters, starting from the area at src. Lowkey a glow-up for your text. πŸ’–

Heads up bestie: a null character in src is not treated as the end of the string. She does not stop for nulls. Periodt.

The conversion result goes into the area dst. Characters that aren't subject to conversion get copied over exactly as they are β€” no notes, no changes, we respect them. πŸ‘‘

When the byte length of the result would exceed maxdst -1, the conversion result gets truncated so it lines up with character boundaries in the EUC code. And dst gets padded with null characters at the end if possible. Both src and dst are represented using EUC code. iykyk.

RkwCvtHan is literally just the wchar_t version of RkCvtHan. Same energy, different type. The arguments that specify a length are regarded as counting character length instead of byte length. 🌈

And here's the wild part β€” NULL can be specified in dst. When you do that, NULL overrides the entire conversion result. Like, no result for you. πŸ’€


πŸ”₯ RETURN VALUE πŸ”₯

This function returns the byte length of the conversion result β€” or the character length if you're using RkwCvtHan. πŸŽ€

But if the value of maxdst is invalid? It returns 0. That's it. That's the whole story. 😭


πŸ’œ SEE ALSO πŸ’œ

(no cap, the original doesn't list any other pages here β€” just the vibes)


This was RKCVTHAN(3) from the Library Functions Manual, brought to you with love, and no cap whatsoever. Thanks for reading bestie, you ate. πŸ’…βœ¨πŸ¦‹πŸŽ€πŸ’–

πŸ“¦ where this page comes from