Open obnys opened 4 years ago
See https://github.com/andig/carddav2fb/blob/master/config.example.php#L100. Seems our default settings arent very good and we should replace with 0 instead of empty?
Oh dear, I'm sorry, I didn't notice I could just adjust the config.php. Now it works perfectly! Again thanks a lot! =) But you're right. "+49" it should either be replaced with '0049' or '0', instead of '' by default.
@obnys here a suggestion:
'phoneReplaceCharacters' => [ // are processed consecutively. Order decides!
'(' => '', // delete separators
')' => '',
'/' => '',
'-' => '',
' ' => '',
'+491' => '01', // domestic numbers without country code
'+492' => '02',
'+493' => '03',
'+494' => '04',
'+495' => '05',
'+496' => '06',
'+497' => '07',
'+498' => '08',
'+499' => '09',
'+49' => '',
'+' => '00' // normalize foreign numbers
]
Thank you @blacksenator =) But wouldn't this already be sufficient?
...
'+49' => '0',
'0049' => '0',
'+' => '00', // keep international area codes for foreign countries intact.
...
Do you think I would really need to add an entry for each area code digit from 1-9?
But wouldn't this already be sufficient?
Think so. Would you kindly open a PR?
@obnys
But wouldn't this already be sufficient?
That depends on your source data and what you want to receive. I only want to have digits as numbers: 03667337171 for domestic numbers or 001476458488 for foreign numbers
I just made a few tests with my data and only this works for me:
'phoneReplaceCharacters' => [ // are processed consecutively. Order decides!
'(' => '', // delete separators
')' => '',
'/' => '',
'-' => '',
' ' => '',
'+49 1' => '01', // domestic numbers without area code
'+49 2' => '02',
'+49 3' => '03',
'+49 4' => '04',
'+49 5' => '05',
'+49 6' => '06',
'+49 7' => '07',
'+49 8' => '08',
'+49 9' => '09',
'+491' => '01',
'+492' => '02',
'+493' => '03',
'+494' => '04',
'+495' => '05',
'+496' => '06',
'+497' => '07',
'+498' => '08',
'+499' => '09',
'+49' => '',
'+' => '00' // normalize foreign numbers
]
@andig - I never thought about this line - so I tried to find information about how strstr
works with assoziativ array (like in this way) - but couldn´t find any proper information.
I never thought about this line - so I tried to find information about how strstr works with assoziativ array (like in this way) - but couldn´t find any proper information.
The thing is that strtr
will replace verbatim, the array case is documented, too. Longest matches are processed first.
We're not using a regex here. Therefore:
$replace = [
'+49' => '0',
'+49 ' => '0',
];
echo(strtr('+49 151 4711', $replace)."\n");
gives
0151 4711
if you omit the second replacement you'll get
0 151 4711
which is ugly. So remember the variant with the space.
Would like a see a PR for improving the default config ;)
Oki, I made a pull request and somehow it landed at jens-maus. I hope I did it correct. Sorry, never did that before and I have zero experience with GitHub :-P
Please use this repo as target- github allows to select that.
Am 20.01.2020 um 22:15 schrieb obnys notifications@github.com:
Oki, I made a pull request and somehow it landed at jens-maus. I hope I did it correct. Sorry, never did that before and I have zero experience with GitHub :-P
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
I have lost track of who is waiting for whom with a PR!
@andig When I wrote the line "I never thought about this line ..." I had overlooked the fact that it was strtr
and not strstr
. My confusion cleared up after reading the documentation for strtr
.
Ping @obnys would you mind to open another PR against this repo?
I can't see a reason keeping this issue open
Greetings, since import without FTP is working, I noticed today, that the international area code is beeing ignored with the imported data. e.g. +49 1234 987654 has been imported as 1234 987654, so the leading "0" has not been added while the international area code has been ignored. Are there intensions to add this? Otherwise I would just use 0049 1234 987654 or leave the area code aside as long as the number is in the same country.