powered by nequal
Home » Text_VariationProducer » Timeline » 778

Changeset 778 -- 2009-04-30 23:29:46

Author
hnw
Comment
クラス定数を追加、UTF8などの扱いが便利になった

Diffs

Text_VariationProducer/trunk/test/Const.php

@@ -0,0 +1,22 @@
+<?php
+include_once(dirname(__FILE__) . '/t/t.php');
+
+$lime = new lime_test;
+$strings1 = new Text_VariationProducer(Text_VariationProducer::UTF16);
+$strings2 = new Text_VariationProducer(Text_VariationProducer::UTF8);
+$strings3 = new Text_VariationProducer(Text_VariationProducer::SJIS);
+$strings4 = new Text_VariationProducer(Text_VariationProducer::SJIS_WIN);
+$strings5 = new Text_VariationProducer(Text_VariationProducer::EUCJP);
+$strings6 = new Text_VariationProducer(Text_VariationProducer::EUCJP_WIN);
+$strings7 = new Text_VariationProducer(Text_VariationProducer::CP51932);
+
+//--
+
+$lime->ok(iterator_count($strings1) === 63488);
+$lime->ok(iterator_count($strings2) === 63488);
+$lime->ok(iterator_count($strings3) === 8995);
+$lime->ok(iterator_count($strings4) === 11439);
+$lime->ok(iterator_count($strings5) === 17861);
+$lime->ok(iterator_count($strings6) === 17861);
+$lime->ok(iterator_count($strings7) === 9025);
+
属性に変更があったパス: Text_VariationProducer/trunk/test/Const.php
___________________________________________________________________
追加: svn:mime-type
+ text/x-php
追加: svn:keywords
+ Id Rev Date
追加: svn:eol-style
+ native

Text_VariationProducer/trunk/src/Text/VariationProducer.php

@@ -1,6 +1,14 @@
<?php
class Text_VariationProducer implements Iterator {
+  const UTF16 = '[\x00-\xd7\xe0-\xff][\x00-\xff]';
+  const UTF8 = '{[\x00-\x7f],[\xc2-\xdf][\x80-\xbf],[\xe0][\xa0-\xbf][\x80-\xbf],[\xe1-\xec][\x80-\xbf][\x80-\xbf],\xed[\x80-\x9f][\x80-\xbf],[\xee\xef][\x80-\xbf][\x80-\xbf]}';
+  const SJIS = '{[\x20-\x7e],[\x81-\x9f\xe0-\xef][\x40-\x7e\x80-\xfc],[\xa0-\xdf]}';
+  const SJIS_WIN = '{[\x20-\x7e],[\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc],[\xa0-\xdf]}';
+  const EUCJP = '{[\x20-\x7e],[\xa1-\xfe][\xa1-\xfe],\x8e[\xa1-\xfe],\x8f[\xa1-\xfe][\xa1-\xfe]}';
+  const EUCJP_WIN = '{[\x20-\x7e],[\xa1-\xfe][\xa1-\xfe],\x8e[\xa1-\xfe],\x8f[\xa1-\xfe][\xa1-\xfe]}';
+  const CP51932 = '{[\x20-\x7e],[\xa1-\xfe][\xa1-\xfe],\x8e[\xa1-\xfe]}';
+
private $patterns = null;
private $rest_producer = null;
private $current_producer = null;