Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 504443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:29:51+00:00 2026-05-13T06:29:51+00:00

i need to parse some paths of an SVG file, they are simple lines.

  • 0

i need to parse some paths of an SVG file, they are simple lines. When retrieving the data i end up with this string:

m 0,666.6479 254.28571,0

According to SVG specifications m denotes a new current point then the following 2 numbers are the position and the laters are relative positions to the first one.

So that would create a line from point (0, 666.6479) to (254.28, 666.64)

How can i parse that in Objective-C so i can end up with those 2 CGPoints or more if there were?

i know that if it finds an m, the following 2 comma separated numbers should be my first point and after each space there are 2 comma separated numbers that i should sum to the current point to get the next one.

What i don’t know if how to parse this correctly.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:29:51+00:00Added an answer on May 13, 2026 at 6:29 am

    I would use C directly, as:

    const char *str = [myString UTF8String];
    
    while(*str)
    {
        switch(*str)
        {
            case 'm':
                state = START;
                break;
            case ' ':
                if(state == START) /* we are just after the m */
                {
                    state = POINT;
                    point = 0;
                    break;
                }
                else if(state == POINT)
                {
                    if(sscanf(str, "%f,%f", &x, &y) != 2)
                        /* handle error; */
                    /* save point somewhere */
                    point++;
                }
                break;
        }
        str++;
    }
    

    Please note that I just written that in the edit box, just take it as an example.

    The other approach is to use NSScanner, but I feel like the above approach is simpler as per your requirements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to parse a file for lines of data that start with this pattern
I need parse through a file and do some processing into it. The file
I need to parse a XML String so I can use some of the
I have some sort of recursive function, but I need to parse a string,
Hi I need parse and deserialize pseudo JSON string. Input data: {aBubbleData[ 'jaja2581' ]={
Possible Duplicate: Parse a JavaScript file through PHP I have some pretty long string
I need to parse an XLIFF file using C#, but I'm having some trouble.
I need to parse some text in a UITextField and turn it into a
Using Ruby, I'm trying to parse some documentation in which I need to split
I've got some HTML files that need to be parsed and cleaned, and they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.