I've got a weird case of a BOM character (%EF%BB%BF) getting prepended to the output of the localization function __($key) in Laravel 5.5
The strange part is that in two subsequent calls of the same function, one will yield the correct result, and the other one won't.. I've opened all my files in Notepad++ displaying all characters, nothing stands out.. I've literally copied the second (correct) line and pasted it in place of the first (incorrect) line - with still the same result!
I'm basically trying to localize the routes being used ($uLng is either 'fr' or 'en') - and a few links are directing towards a specific anchor on the page, which I localized using __()
Here is the code of my view:
<a class="floatingMenuLink" href="{{ route('public_features.' . $uLng) }}#{{ __('pub_how_it_works.routeIdSecurity') }}">{{ __('global.publicMenuSecurity') }}</a>
<a class="floatingMenuLink" href="{{ route('public_features.' . $uLng) }}#{{ __('pub_how_it_works.routeIdSecurity') }}">{{ __('global.publicMenuSecurity') }}</a>
Pretty similar right?
The first link generated is : http://localhost/fonctionnement#%EF%BB%BFsecurite
The second link generated is : http://localhost/fonctionnement#securite
Further testing shows that:
- using a different key (ie 'pub_how_it_works.foo' instead of 'pub_how_it_works.routeIdSecurity') yields the same issue for the first link
- replacing the __() function by static text resolves the issue
So.. I really think the problem comes from localization, but I have no clue how to solve it..