com.github.javafaker.service.FakerIDN Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javafaker Show documentation
Show all versions of javafaker Show documentation
This library is a port of Ruby's stympy/faker gem (as well as Perl's Data::Faker library) that generates fake data.
It's useful when you're developing a new project and need some pretty data for showcase.
package com.github.javafaker.service;
import java.net.IDN;
/**
* Created by tshick on 10/30/16.
*/
public class FakerIDN {
/**
* {@link IDN#toASCII(String)} is too picky for our needs. It was throwing exceptions for fa.yml and
* he.yml as they're Bidi languages and something was causing them to die. This is kind of a brute force
* fix but it appears to fix the issue.
*/
public static final String toASCII(String in) {
try {
return IDN.toASCII(in);
} catch (Exception e) {
// let's continue with the character by character encoding hack.
}
final StringBuilder sb = new StringBuilder();
for (int i=0;i