From 7f4a6b624f2da12e5cbd2398dd57c8ac7f1aa707 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 22 Nov 2021 08:56:28 -0800 Subject: [PATCH] phone number --- t_phonenumber_egypt_3_4.go | 16 ++++++++++++++++ t_phonenumber_egypt_4_4.go | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/t_phonenumber_egypt_3_4.go b/t_phonenumber_egypt_3_4.go index 110182f..310dcde 100644 --- a/t_phonenumber_egypt_3_4.go +++ b/t_phonenumber_egypt_3_4.go @@ -2,6 +2,7 @@ package arbitrary import ( "fmt" + "strings" ) func (arb T) phonenumber_egypt_3_4(areacode string) string { @@ -31,6 +32,21 @@ func (arb T) phonenumber_egypt_3_4(areacode string) string { result = fmt.Sprintf(format, areacode, localpart1, localpart2) } + { + if 0 == arb.randomness.Intn(4) { + result = strings.ReplaceAll(result, "0", "٠") + result = strings.ReplaceAll(result, "1", "١") + result = strings.ReplaceAll(result, "2", "٢") + result = strings.ReplaceAll(result, "3", "٣") + result = strings.ReplaceAll(result, "4", "٤") + result = strings.ReplaceAll(result, "5", "٥") + result = strings.ReplaceAll(result, "6", "٦") + result = strings.ReplaceAll(result, "7", "٧") + result = strings.ReplaceAll(result, "8", "٨") + result = strings.ReplaceAll(result, "9", "٩") + } + } + return result } diff --git a/t_phonenumber_egypt_4_4.go b/t_phonenumber_egypt_4_4.go index 083c76a..922238e 100644 --- a/t_phonenumber_egypt_4_4.go +++ b/t_phonenumber_egypt_4_4.go @@ -2,6 +2,7 @@ package arbitrary import ( "fmt" + "strings" ) func (arb T) phonenumber_egypt_4_4(areacode string) string { @@ -31,6 +32,20 @@ func (arb T) phonenumber_egypt_4_4(areacode string) string { result = fmt.Sprintf(format, areacode, localpart1, localpart2) } + { + if 0 == arb.randomness.Intn(4) { + result = strings.ReplaceAll(result, "0", "٠") + result = strings.ReplaceAll(result, "1", "١") + result = strings.ReplaceAll(result, "2", "٢") + result = strings.ReplaceAll(result, "3", "٣") + result = strings.ReplaceAll(result, "4", "٤") + result = strings.ReplaceAll(result, "5", "٥") + result = strings.ReplaceAll(result, "6", "٦") + result = strings.ReplaceAll(result, "7", "٧") + result = strings.ReplaceAll(result, "8", "٨") + result = strings.ReplaceAll(result, "9", "٩") + } + } + return result } -