Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chinese encode error #14

Open
ytx0574 opened this issue Jul 25, 2019 · 1 comment
Open

Chinese encode error #14

ytx0574 opened this issue Jul 25, 2019 · 1 comment

Comments

@ytx0574
Copy link

ytx0574 commented Jul 25, 2019

[mp3File setTitle:@"囧"];
[mp3File setArtist:@"aa"];
[mp3File setAlbum:@"aa"];
[mp3File setLyrics:@"aa"];

[mp3File setArtwork:image isPNG:false];
[mp3File writeTag];

D96C8A7A-04E2-41DE-9225-D744C7E2A621

@ytx0574
Copy link
Author

ytx0574 commented Jul 29, 2019

fix;

  • (NSArray*)createFrame:(NSArray*)frame withContent:(NSString*)str {
    NSMutableArray *bytes = [[NSMutableArray alloc] initWithArray:frame];
    const char *strPtr = [str cStringUsingEncoding:NSUTF16StringEncoding];

    NSMutableArray *content = [[NSMutableArray alloc] init];

    // Move past the padding in the beginning of the string
    while(*strPtr == '\0') {
    strPtr++;
    }

    // Add padding to beginning
    [content addObject:@((uint8)1)]; //此处要修改(ISO-8859-1) = 1, (Unicode) = 1

    // Copy the string to a new buffer
    while(strPtr != '\0') {
    [content addObject:@(
    (strPtr++))];
    }

    // Add padding to end character
    [content addObject:@((uint8)0)];

    NSMutableArray *sizeArr = [Toolbox toByteArray:(uint32)content.count];
    [sizeArr removeObjectAtIndex:0];

    // Create the frame
    [bytes addObjectsFromArray:sizeArr];
    [bytes addObjectsFromArray:content];

    return bytes;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant