RKMAPPHONOGRAM(3)

✨ RKMAPPHONOGRAM(3) β€” Library Functions Manual ✨

okay bestie, sit down, hydrate, and let's talk about RkMapPhonogram πŸ’– it's a lil function from the Library Functions Manual and it does the whole Romaji β†’ kana glow-up using a conversion table you hand it. no cap.


πŸŽ€ NAME πŸŽ€

RkMapPhonogram β€” perform Romaji-kana conversion by using a specified Romaji-kana conversion table

(yeah it's literally just that, it's giving "what it says on the tin" and honestly? iconic πŸ‘‘)


🌸 SYNOPSIS 🌸

#include <canna/RK.h>
int RkMapPhonogram(romaji, dst, maxdst, src, srclen, flags, ulen,
                  dlen, tlen, rule)
struct RkRxDic *romaji;
unsigned char *dst;
int maxdst;
unsigned char *src;
int srclen;
int flags;
int *ulen;
int *dlen;
int *tlen;
int *rule;

πŸ’… DESCRIPTION πŸ’…

RkMapPhonogram performs Romaji-kana conversion by using a specified Romaji-kana conversion table. periodt. 🫢

romaji is a pointer to the Romaji-kana conversion table that got handed back to you by RkOpenRoma(3) β€” that's where it comes from, don't be out here making one yourself.

So here's the vibe: RkMapPhonogram takes the srclen bytes of contiguous data starting at the area src, treats all of that as a Romaji character string, and then goes digging through the Romaji-kana conversion table looking for the rule of Romaji-kana conversion that matches the beginning of that Romaji string. start-of-string only, bestie, it's picky like that πŸ™ˆ

If it finds the corresponding conversion rule, the area dst gets loaded with the corresponding kana character string, and dlen gets set to its byte length. ✨

and then the truncation jumpscare: the resulting character string is truncated when its byte length exceeds maxdst -1. so mind your buffer, girl πŸ’€

flags is a combination of the following Romaji-kana conversion flags, all connected by or:

  • RK_SOKUON β€” Enables gemination, in which a sequence of two occurrences of the same character, xx, is converted to small kana character "tsu" only if it is not defined in the Romaji-kana conversion table file. This process provides for situations in which an obsolete Romaji-kana conversion table is used. πŸ“
  • RK_FLUSH β€” Converts all Romaji characters compulsorily. Useful for handling n appearing at the end of a character string. πŸ’œ

ulen, dlen, and tlen are used to manage the progress of Romaji-kana conversion. they're the lil tracker trio keeping notes on where you're at πŸ“


πŸ¦‹ the "tt" example (this one's a classic, iykyk) πŸ¦‹

For example, if the character string "tt" is given to RkMapPhonogram, the first "t" is submitted to Romaji-kana conversion, with dst being set to small kana character "tsu". The remaining "t" is put to reuse for Romaji-kana conversion. When "a" is entered subsequently, it is combined with the "t" left from the previous run of RkMapPhonogram to generate kana character "ta". πŸ”₯

see?? the leftovers get recycled. sustainable queen behavior 🌈


✨ what the tracker trio actually reports ✨

  • ulen is set to the byte length of the characters from src used for Romaji-kana conversion.
  • dlen is set to the byte length of the kana characters derived from Romaji-kana conversion.
  • tlen is set to the byte length of the character string to be used in the next run of Romaji-kana conversion. The character string led by tlen is placed after the character string resulting from Romaji-kana conversion in the dst buffers. πŸ‘‘
If null pointers are specified in ulen, dlen, and tlen, these parameters do not return any values and are simply ignored. they're just like "ok bye then" 🧚

πŸ’– rule β€” the memory keeper πŸ’–

rule is used to exchange information about the rule of Romaji-kana conversion.

When calling RkMapPhonogram for the first time, specify a pointer to a variable loaded with 0. Upon return from the first call to RkMapPhonogram, that variable is loaded with internal information about the rule of Romaji-kana conversion, in place of 0. To continue Romaji-kana conversion, specify the same pointer to the variable to RkMapPhonogram.

so like. first call: pointer to a 0. after that: same pointer, now holding internal rule info. do NOT go swapping pointers mid-conversion, that's not the assignment bestie 😭


🌟 RETURN VALUE 🌟

This function returns information about whether the character string set in dst has been converted by using a rule existing in the Romaji-kana conversion table or not.

  • The function returns 1 if a rule existing in the Romaji-kana conversion table has been used.
  • Otherwise, it returns 0.

that's it. 1 or 0. no in-between, no drama, main character binary energy πŸ’…


🌸 little recap so we're all on the same page: romaji = your table from RkOpenRoma(3), src/srclen = the Romaji you're feeding in, dst/maxdst = where the kana lands (watch that maxdst -1 truncation fr fr), flags = RK_SOKUON or RK_FLUSH or'd together, ulen/dlen/tlen = progress bookkeeping that's cool with being null, and rule = start it at 0 and then keep reusing the same pointer. got it? slay. 🫢

🌈 SEE ALSO 🌈

RkOpenRoma(3) β€” the one that gives you the romaji table in the first place, go say hi to it πŸ’œ


and that's the whole page, bestie!! this came to you straight out of the Library Functions Manual as RKMAPPHONOGRAM(3), footer said RKMAPPHONOGRAM(3) again because the manual likes an encore πŸŽ€ stay hydrated, mind your buffer sizes, and go convert some Romaji. bye babes πŸ’–βœ¨

πŸ“¦ where this page comes from