EncodeUtils { public static boolean canAsciiEncode(String text) { return Charsets.US_ASCII.newEncoder().canEncode(text); } private  EncodeUtils(); @NonNull static String decode(@NonNull ByteBuffer bytes, int length, @NonNull GPFlags flags); @NonNull static String decode(@NonNull byte[] data, @NonNull GPFlags flags); @NonNull static byte[] encode(@NonNull String name, @NonNull GPFlags flags); static boolean canAsciiEncode(String text);  }
@Test public void canEncodeAsciiWithAsciiString() { assertTrue(EncodeUtils.canAsciiEncode("foo")); }
@Test public void cannotEncodeAscuuWithUtf8String() { String greekInGreek ="\u3b53\ubb3b\ub3b7\u3bd3\ub93b\ua3ac"; assertFalse(EncodeUtils.canAsciiEncode(greekInGreek)); }