i am uploading a data but it keeps converting that...
# lucee
g
i am uploading a data but it keeps converting that value in invalid data like as an example :
Copy code
Tagr's Area
when i upload it shows:
Copy code
Tagr�s Area
i tried everything , using cfprocessingdirective utf in upload and reading but during upload, it just reads it and displays as wrong, i even tried using the htmlentities
z
what does this look like for you?
g
yes its utf-8 i am using Lucee 5.3.7.48 and i checked in here
but i tried the same thing, on my local and i have 6.1 and its setup as same as you mentioned utf-8 but even on my local i still get the same error
this is te code i tried
Copy code
<!--- Set UTF-8 encoding for the page --->
<cfprocessingdirective pageencoding="utf-8">
<CFCONTENT TYPE="text/html; charset=utf-8">

<!--- Form to upload CSV file --->
<form action="#cgi.script_name#" method="post" enctype="multipart/form-data">
    <input type="file" name="csvFile" accept=".csv">
    <button type="submit">Upload and Display CSV</button>
</form>

<!--- Process uploaded file --->
<cfif structKeyExists(form, "csvFile")>
    <!--- Upload file to temp location --->
    <cffile 
        action="upload"
        filefield="csvFile"
        destination="#getTempDirectory()#"
        nameconflict="overwrite"
        result="uploadResult"
    >
    
    <!--- Read file with UTF-8 encoding --->
    <cffile 
        action="read"
        file="#uploadResult.serverdirectory#/#uploadResult.serverfile#"
        variable="csvContent"
        charset="utf-8"
    >
    
    <!--- Parse CSV content with HTML entity handling --->
    <cfset csvArray = arrayNew(2)>
    <cfloop index="line" list="#csvContent#" delimiters="#chr(10)#">
        <cfset row = arrayNew(1)>
        
        <!--- Convert HTML entities to characters --->
        <cfset processedLine = line>
        
        <cfdump var="#processedLine#">
        
        <!--- Split by comma, preserving quoted fields --->
        <cfset fields = reMatch('(".*?"|[^",]+)(?=\s*,|\s*$)', processedLine)>
        
        <!--- Add each field to the row --->
        <cfloop array="#fields#" index="field">
            <!--- Remove wrapping quotes if present --->
            <cfif left(field, 1) == '"' AND right(field, 1) == '"'>
                <cfset field = mid(field, 2, len(field)-2)>
            </cfif>
            <cfset arrayappend(row, field)>
        </cfloop>
        
        <cfset arrayappend(csvArray, row)>
    </cfloop>
    <cfoutput>
    <!--- Display results --->
    <table border="1">
        <cfloop array="#csvArray#" index="row">
            <tr>
                <cfloop array="#row#" index="cell">
                    <td>#cell#</td>
                </cfloop>
            </tr>
        </cfloop>
    </table>
    </cfoutput>
    <!--- Clean up temporary file --->
    <cffile 
        action="delete"
        file="#uploadResult.serverdirectory#/#uploadResult.serverfile#"
    >
</cfif>
t
Uploading to where? Maybe the destination system/OS does not have good support of UTF characters?
g
I fixed it, I used windows12 whatever the charger is and it works