Skip to content

Commit

Permalink
pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe committed Apr 3, 2024
1 parent 3f6057c commit 6ae2a1e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions impl/internal/did/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,19 @@ func keyTypeForJWK(jwk jwx.PublicKeyJWK) int {
return -1
}

// chunkTextRecord splits a text record into chunks of 255 characters
// chunkTextRecord splits a text record into chunks of 255 characters, taking into account multi-byte characters
func chunkTextRecord(record string) []string {
var chunks []string
for len(record) > 255 {
chunks = append(chunks, record[:255])
record = record[255:]
runeArray := []rune(record) // Convert to rune slice to properly handle multi-byte characters
for len(runeArray) > 0 {
if len(runeArray) <= 255 {
chunks = append(chunks, string(runeArray))
break
}

chunks = append(chunks, string(runeArray[:255]))
runeArray = runeArray[255:]
}
chunks = append(chunks, record)
return chunks
}

Expand Down

0 comments on commit 6ae2a1e

Please sign in to comment.