Mysql νκ΅μ΄ encoding
Mysqlκ³Ό νκΈμ κ°μ΄ μ¬μ©νμλμ λΆνΈν¨
June 27, 2024
νμΌμ μ μ₯ν λ 무쑰건 UTF-8 ν¬λ©§μΌλ‘ μ μ₯μ νλκ² μ’μ.
νκ΅μ΄ νμΌ μ μ₯μ νμΌλͺ μ΄ UTF-8μ΄ μλ Unicode NFD λ²μ μΌλ‘ μ μ₯μ΄ λλ€κ³ ν¨ (commonly used in macOS filesystem). μΆνμ νκ΅μ΄ κ²μμ ν΄λ 맀μΉμ΄ λμ§ μμ.
μμ:
php
1$file = $request->file('uploads');2$originalFileName = $file->getClientOriginalName();34// Convert the filename to UTF-8 encoding5/// νκ΅μ΄ κ²μμ νμΌλͺ μ΄ UTF-8μ΄ μλ Unicode NFD λ²μ μΌλ‘ μ μ₯μ΄ λλ€κ³ ν¨ (commonly used in macOS filesystem).6/// μΆνμ νκ΅μ΄ κ²μμ ν΄λ 맀μΉμ΄ λμ§ μμ.7if (class_exists('Normalizer') && Normalizer::isNormalized($originalFileName, Normalizer::FORM_C) === false) {8 $fileName = Normalizer::normalize($originalFileName, Normalizer::FORM_C);9} else {10 $fileName = $originalFileName;11}1213$fileSize = $file->getSize();1415$log = MasterRightsUploadLogs::create([16 'file_name' => $fileName,17 'file_size' => $fileSize,18 'user_id' => auth()->user()->id,19 'status' => 'processing',20]);