Skip to content

Instantly share code, notes, and snippets.

@danielmitd
Created December 18, 2015 13:48
Show Gist options
  • Select an option

  • Save danielmitd/47173176c5a227915c0d to your computer and use it in GitHub Desktop.

Select an option

Save danielmitd/47173176c5a227915c0d to your computer and use it in GitHub Desktop.
cp1252-issue-test-case
<?php
$testData = [
"Senior IT Consultant / Project Manager &#8211; Pharma Industry f/m",
"Business Development Manager &#8211; High-Tech & Precision Manufacturing f/m",
"Comos Specialist &#8211; Pharma Engineering f/m",
"Medizintechniker/in 60 &#8211; 80%",
"Informatikrevisor/in &#8211; IT-Sicherheitsspezialist/in",
"Unterhaltsmechaniker/in 3&#8208;Schicht",
"Chef(fe) d&#39;équipe en Chauffage - Ventilation - Climatisation",
"Informatiker EFZ/HF/FH &#8211; Applikationsentwickler (w/m)",
"&#8203;Junior Editor 50%",
"Dipl. Pflegefachfrau/-Mann HF/ DNII/ DNI/ FaGe/ FaBe 80 &#8211; 100%",
"Senior Test Engineer General Counsel &#8211; Anti Money Laundering (AML) / Financial Crime Complianc",
"Product Manager &#8211; Data Protection Core Security (80% - 100%)",
"Senior Project Manager &#8211; Fund industry environment",
"Finanzierungsexpertin / Finanzierungsexperte (80-100%) &#8211; Marktgebiet Schwyz/Uri",
"Relationship Manager Executives & Entrepreneurs, Basel (80 &#8211; 100%)",
"IT System Ingenieur &#8211; IT Generalistin / Generalist - Fides Treasury Services AG",
"Sourcing & Vendor Management &#8211; Strategic Sourcer (IT Outsourcing / IT Consulting)",
"Privatkundenberaterin / Privatkundenberater im Private & Wealth Management Clients (80 &#8211; 100%)",
"Test Data Manager and Test Engineer for &#8220;Client Reference Data&#8221; (CIF/CRD)",
"Solution Architect &#8222;Securities Processing, Online & Output&#8220;, Luzern",
"Solution Engineer 80-100% &#8211; Fides Treasury Services AG",
"Aussendienst Mitarbeiter &#8211; Sachversicherungen (m/w)",
"Assistante à 50/60% (H/F) pour l&#8217;agence de Fribourg",
"Assistante à 50/60% (H/F) pour l&#8217;agence de Fribourg - Entreprise Générale",
"Dipl. Pflegefachfrau/ Dipl. Pflegefachmann HF/FH Medizin / Akutgeriatrie 80 &#8211; 100 %",
"Chef/fe de projets multidisciplinaires Léman 2030 - Extension de capacité du n&#339;ud de Genève",
"Chef/fe de projets TechFer &ndash; Léman 2030 Extension de capacité du n&#339;ud de Genève",
"Associate Director Marketing, Brand Lead New Products &#8211;The Netherlands, Belgium, Switzerland, ",
"Service Specialist &#8211; Retail Kundendienst",
"Business Specialist &#8211; Businesskundenbetreuung und Sales",
"Store Leader &#8211; Retail Store Director",
"Apprenant/e employé/e de commerce profil E ou M à partir d&#8217;août 2016",
"Sekretär/in &#8211; Assistent/in (Schwerpunkt: Englisch)",
"Personal- & Finanzfachmann (80&#8211;100%) Soziale Institution",
"Co-Leiter/-in Wohnen, GL-Mitglied Sozial- und Gesundheitswesen 80 &#8211; 100%",
" Dipl. Pflegefachfrau/-mann HF oder FH, 90 &#150;- 100% ",
" Medizinische Praxisassistentin oder Pflegefachfrau 80 &#150; 100% ",
"Sachbearbeiter/in Empfang&#8201;/&#8201;Telefonzentrale und weitere administrative Tätigkeiten (100%",
"Responsable de l&#8217;unité Risques et Management d&#8217;entreprise",
"L&#8217;oréal - hr business partner & talent acquistion manager",
"L&#8217;oréal - pr manager (CONSUMER brands)",
"L&#8217;oréal - marketing assistent 80% (Befristeter Vertrag)",
"Vendeur véhicules d&#039;occasion",
"Mécanicien en maintenance d&#039;automobiles (m/w)",
"Responsable département traitement de l&#8217;eau",
"Stagiaire H/F &#8211; Production voyages/loisirs (bilingue FR/ALL)",
"Aussendienstmitarbeiter(in) - sanitär&#8221;",
"Responsable Comptabilité / Ressources humaines (80&#8211;100%)",
];
function convert($string)
{
$cp1252Map = [
'&#128;' => '&#8364;',
'&#130;' => '&#8218;',
'&#131;' => '&#402;',
'&#132;' => '&#8222;',
'&#133;' => '&#8230;',
'&#134;' => '&#8224;',
'&#135;' => '&#8225;',
'&#136;' => '&#710;',
'&#137;' => '&#8240;',
'&#138;' => '&#352;',
'&#139;' => '&#8249;',
'&#140;' => '&#338;',
'&#142;' => '&#381;',
'&#145;' => '&#8216;',
'&#146;' => '&#8217;',
'&#147;' => '&#8220;',
'&#148;' => '&#8221;',
'&#149;' => '&#8226;',
'&#150;' => '&#8211;',
'&#151;' => '&#8212;',
'&#152;' => '&#732;',
'&#153;' => '&#8482;',
'&#154;' => '&#353;',
'&#155;' => '&#8250;',
'&#156;' => '&#339;',
'&#158;' => '&#382;',
'&#159;' => '&#376;'
];
$string = strtr($string, $cp1252Map);
return mb_convert_encoding($string, "cp1252", "HTML-ENTITIES");
}
foreach ($testData as $line) {
echo convert($line) . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment