original_string: private function convertToHtmlEntities(string $htmlContent, string $charset = 'UTF-8'): string
      {
          set_error_handler(function () { throw new \Exception(); });
  
          try {
              return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset);
          } catch (\Exception $e) {
              try {
                  $htmlContent = iconv($charset, 'UTF-8', $htmlContent);
                  $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
              } catch (\Exception $e) {
              }
  
              return $htmlContent;
          } finally {
              restore_error_handler();
          }
      }
code: private function convertToHtmlEntities(string $htmlContent, string $charset = 'UTF-8'): string
      {
          set_error_handler(function () { throw new \Exception(); });
  
          try {
              return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset);
          } catch (\Exception $e) {
              try {
                  $htmlContent = iconv($charset, 'UTF-8', $htmlContent);
                  $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
              } catch (\Exception $e) {
              }
  
              return $htmlContent;
          } finally {
              restore_error_handler();
          }
      }
code_tokens: private function convertToHtmlEntities ( string $ htmlContent , string $ charset = 'UTF-8' ) : string { set_error_handler ( function ( ) { throw new \ Exception ( ) ; } ) ; try { return mb_convert_encoding ( $ htmlContent , 'HTML-ENTITIES' , $ charset ) ; } catch ( \ Exception $ e ) { try { $ htmlContent = iconv ( $ charset , 'UTF-8' , $ htmlContent ) ; $ htmlContent = mb_convert_encoding ( $ htmlContent , 'HTML-ENTITIES' , 'UTF-8' ) ; } catch ( \ Exception $ e ) { } return $ htmlContent ; } finally { restore_error_handler ( ) ; } }
docstring: Converts charset to HTML-entities to ensure valid parsing.
docstring_tokens: Converts charset to HTML - entities to ensure valid parsing .