¥â¥¸¥å¡¼¥ë¤È¤·¤Æºî¤Ã¤Æ¤ß¤Þ¤·¤¿¡£
»ä¤Î¥¹¥¯¥ê¥×¥È¤Î¾ì¹ç¤Ï¥Ì¥ëʸ»ú¤òºï½ü¤¹¤ë¤è¤¦¤Ë¤·¤Æ¤¢¤ê¤Þ¤¹¡£
ʸ»ú¥³¡¼¥É¤ÏShift-JIS¤Î¤ß¤Ç¡¢Unicode¤Ë¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó¡£
¥Õ¥¡¥¤¥ë¤Ç¤Ï»î¤·¤Æ¤¤¤Þ¤»¤ó¤¬¡¢bload¤Ç¤âÂбþ¤·¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹¡£
#module
// ·¿¤ò var ¤Ç¤Ï¤Ê¤¯ str ¤Ë¤¹¤ë¤È¥Ì¥ëʸ»ú°Ê¹ß¤¬ÀÚ¤êÍî¤È¤µ¤ì¤ë¤Î¤ÇÃí°Õ
#deffunc RemoveNullChar var text, \
local index, local merged
// ¢¬ºÆµ¢¤¹¤ë¤Î¤Ç¥í¡¼¥«¥ëÊÑ¿ô¤Ç¤¢¤ë¤³¤È
// ¥Ì¥ëʸ»ú¤Î¼¡¤Îʸ»ú¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹
index = strlen(text) + 1
repeat
if (index == varsize(text)) : break
if (peek(text, index) == 0) : index++ : else : break //2ʸ»ú°Ê¾å¤Î¥Ì¥ëʸ»ú¤ÎϢ³¤ò¸¡ÃÎ
loop
// ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ï¥Ì¥ëʸ»ú¤¬Ï¢Â³¤·¤Æ¤¤¤ì¤Ð¡¢ºÇ¸å¤Î¥Ì¥ëʸ»ú + 1 ¤ò»Ø¤¹¡£
// ¨¤Á ¥¤¥ó¥Ç¥Ã¥¯¥¹¡áÊÑ¿ô¥µ¥¤¥º ¤Ç¤¢¤ì¤Ð½ªÃ¼°Ê³°¤Ë¥Ì¥ëʸ»ú¤¬Ìµ¤¤¤³¤È¤ò¼¨¤¹
if (index == varsize(text)) : return
// ÊÑ¿ô½é´ü²½
sdim merged, strlen(text) + (varsize(text) - index) // ¥Ì¥ëʸ»ú¤Þ¤Ç¤Îʸ»ú¿ô + (Á´Âοô - ¥Ì¥ëʸ»ú¤Î¼¡¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹): ¨¤Á»Ä¤ê¤Îʸ»ú¿ô
// ÊÑ¿ô¤ËÆâÍƤò¥á¥â¥ê¥³¥Ô¡¼ (ÉáÄ̤Υ¤¥³¡¼¥ëÂåÆþ¤äʸ»úÎó´ØÏ¢¤ÎÌ¿Îá¤À¤È¡¢¥Ì¥ëʸ»ú°Ê¹ß¤¬ÀÚ¤êÍî¤È¤µ¤ì¤Æ¤·¤Þ¤¦)
memcpy merged, text, strlen(text) // ¥Ì¥ëʸ»ú¤Þ¤Ç¤ò¥³¥Ô¡¼
memcpy merged, text, varsize(text) - index, strlen(text), index // ¥Ì¥ëʸ»ú°Ê¹ß¤ò¥³¥Ô¡¼
// ¥Ì¥ëʸ»ú¤Î¼¡¤Îʸ»ú¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ÊÑ¿ô¥µ¥¤¥º¤ËËþ¤¿¤Ê¤±¤ì¤Ð»Ä¤ê¤¬¤¢¤ë¤È¤¤¤¦¤³¤È¤Ê¤Î¤ÇºÆµ¢½èÍý¤ò¹Ô¤¦
if (index < varsize(text)) : RemoveNullChar merged
// ¤³¤Î»þÅÀ¤Ç½ªÃ¼°Ê³°¤Î¥Ì¥ëʸ»ú¤Ïºï½ü¤µ¤ì¤Æ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
sdim text, strlen(merged)
text = merged
return
#global
text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ¤¢¤¤¤¦¤¨¤ª¤«¤¤¯¤±¤³0123456789"
poke text, 5, 0 // F ¤òNULLʸ»ú¤Ë
poke text, 6, 0 // G ¤òNULLʸ»ú¤Ë
poke text, 15, 0 // P ¤òNULLʸ»ú¤Ë
wpoke text, 31, 0 // ¤¦ ¤òNULLʸ»ú¤Ë (ÆüËܸì¤Ï2¥Ð¥¤¥È)
mes "ÊÑ´¹Á°"
mes text
mes
RemoveNullChar text
mes "ÊÑ´¹¸å"
mes text