JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<body>
  <h3> Click the button to download the CSV file </h3>
      <input id="SJISText" value="髙橋,高橋" type="text" />
  <button onclick="download_csv_file($('#SJISText'))"> Download CSV </button>
</body>

JavaScript

//create a user-defined function to download CSV file   
function download_csv_file(str) {  
  
    //define the heading for each row of the data  
    var csv = 'FirstName,LastName\n'+str.val();  
      
   
    //display the created CSV data on the web browser   
    document.write(csv);  
  
     
    var hiddenElement = document.createElement('a');  
    hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);  
    hiddenElement.target = '_blank';  
      
    //provide the name for the CSV file to be downloaded  
    hiddenElement.download = 'CharacterGarble.csv';  
    hiddenElement.click();  
}