title: Generating arbitrary (legal) Unicode character with scalacheck?
body: <p>I'm trying to create a generator that produces (non-zero-length) legal unicode strings, with scalacheck 1.6.6 and specs 1.7 (scala 2.8.1).</p>
  
  <p>I hoped I could just create generators like:</p>
  
  <pre><code>object Generators {
    def unicodeChar: Gen[Char] = 
      choose(Math.MIN_CHAR, Math.MAX_CHAR).map(_.toChar).filter(
        c =&gt; Character.isDefined(c))
    def unicodeStr: Gen[String] = for(cs &lt;- listOf1(unicodeChar)) yield cs.mkString
  }
  </code></pre>
  
  <p>...then use them from specs like:</p>
  
  <pre><code>import org.specs.Specification
  import org.specs.matcher.ScalaCheckMatchers
  
  object CoreSpec extends Specification with ScalaCheckMatchers {        
    "The core" should {    
      "pass trivially" in {
        Generators.unicodeStr must pass((s: String) =&gt; s == s)
      }
    }
  }
  </code></pre>
  
  <p>But, it seems that using filter in unicodeChar causes a problem:</p>
  
  <pre><code>Specification "CoreSpec"
    The core should
    x pass trivially
      Gave up after only 64 passed tests. 500 tests were discarded.
  </code></pre>
  
  <p>If I remove the filter from unicodeChar, my test passes, but I run into other problems later, since my strings are not always well-defined unicode.</p>
  
  <p>Thanks in advance for any suggestions on how to achieve this.</p>