Files
PoyoLang/PoyoLang.Translator/PoyoLangTranslator.cs
2025-05-16 14:07:02 +02:00

39 lines
856 B
C#

using System.Text;
namespace PoyoLang.Translator;
public partial class PoyoLangTranslator
{
public string TranslateToPoyo(ReadOnlySpan<char> text)
{
var output = new StringBuilder(text.Length);
while (text.Length > 0)
{
NextLetter(ref text, output);
// Add space if not reached the end
if (text.Length > 0)
{
output.Append(' ');
}
}
return output.ToString();
}
public string TranslateFromPoyo(ReadOnlySpan<char> text)
{
var output = new StringBuilder(text.Length);
while (text.Length > 0)
{
// Skip spaces (those are not used in this language)
text = text.TrimStart(' ');
FromPoyo(ref text, output);
}
return output.ToString();
}
}