Skip to content

Commit

Permalink
Now emojis are supported?? Please 🐣
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Sep 30, 2024
1 parent f5b12ec commit 855c340
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/nextjs/app/create/_components/generateTokenURI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ const generateTokenURI = (description: string, image: string) => {
// Convert the metadata object to a JSON string
const jsonString = JSON.stringify(metadata);

// Encode the JSON string as base64
const base64Encoded = btoa(jsonString);
// Encode the JSON string as base64 using a UTF-8 safe method
const base64Encoded = utf8ToBase64(jsonString);

// Construct the data URI
return `data:application/json;base64,${base64Encoded}`;
};

// Function to encode a UTF-8 string to base64
const utf8ToBase64 = (str: string) => {
return window.btoa(unescape(encodeURIComponent(str)));
};

export default generateTokenURI;

0 comments on commit 855c340

Please sign in to comment.