Module ce_xlat

Description

Generic character translation server.

This is not efficient. An efficient implementation would compile the candidates into a finite-state machine first. This doesn't do that.

Function Index

Exported Functions
send/2Sends a character or characters to an xlat server for translation.
server/2Spawned by start/2, should not be called directly by user code.
start/2Starts an xlat server.

Exported Functions

send/2

send(xlat(), char() | string()) -> ok

Sends a character or characters to an xlat server for translation.

server/2

server(candidates(), Dest::pid()) -> never_returns()

Spawned by start/2, should not be called directly by user code.

start/2

start(candidates(), Dest::pid()) -> xlat()

Starts an xlat server. Candidates is a list of pairs of strings. Characters are sent to the xlat server with the send/2 function. When they match the left string of a candidate, the right string is sent to Dest instead. If they do not match any candidates, they are sent through unaltered. Characters are sent to Dest in the form {xlat(), xlat_char, char()}. Note that if two candidates have the same left string, the result of the translation is undefined. Also note that if one candidate has a left string that is a prefix of another candidate's left string, that second candidate will never match (the shorter one will always be matched first.)