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 8189139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:10:18+00:00 2026-06-07T03:10:18+00:00

I have this code in Javascript: var f = chr(50) + chr(0) + chr(1)

  • 0

I have this code in Javascript:

var f = chr(50) + chr(0) + chr(1) + chr(64) + chr(24) + chr(0) + chr(0) + chr(1) + chr(159) + chr(13) + chr(0) + chr(0) + chr(224) + chr(7);

function chr(AsciiNum) {
    return String.fromCharCode(AsciiNum);
}

console.log outputs this as

2@
à 

With a length of 14.

I am trying to port it to Objective C.
I tried doing the following:

NSString *f = [NSString stringWithFormat:@"%c%c%c%c%c%c%c%c%c%c%c%c%c%c",50, 0 ,1, 64 , 24 , 0 , 0 , 1, 159,  13 , 0 , 0 , 224 , 7];

But I received a different output to the javascript code when using NSLog:

2@ü

What am I doing wrong? Is a character set issue?

  • 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-06-07T03:10:21+00:00Added an answer on June 7, 2026 at 3:10 am

    Well, it seems that your problems stem from the fact that NSString’s ASCII support is limited to a strict 7-bit ASCII encoding, which means only the chars 0-127 are supported. You’ll have to use a different data type to store your chars, and that different data type is unichar, which supports 2^15-1 precisely because it is unsigned short. However, you will need to convert it to an NSString which operates in Unicode with this category:

    @interface NSString (MNNSStringWithUnichar)
    + (NSString *) stringWithUnichar: (unichar) value;
    @end
    
    @implementation NSString (MNNSStringWithUnichar)
    
    + (NSString *) stringWithUnichar:(unichar) value {
         NSString *str = [NSString stringWithFormat: @"%C", value];
         return str;
    }
    @end
    

    Or simply NSLog(@"%C", value);

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

Sidebar

Related Questions

I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>
I have this code: <script type=text/javascript> var maxLength=10; function charLimit(el) { if (el.value.length >
Okay, I have this code: <script language=javascript type=text/javascript> <!-- function requestPage(page) { var request
I have this code: <script type=text/javascript> var loader = #loader; $(function() { $(#selUsers).change(function() {
I have this code: <script type=text/javascript> function showTotal(form, totalEl) { var el, els =
I have this code: <script type=text/javascript> $(document).ready(function(){ var id = 'i1'; var image =
I have this javascript code: $(document).ready(function() { var leftHeight = $('#maincontent').height(); $('#sidemenu').css({'height':leftHeight}); }); This
I have this JavaScript code: <script type=text/javascript> function timeMsg() { var t=setTimeout(doRedirect(),10000); } function
let's say I have this code in javascript: function doAnAjaxCall () { var xhr1
I have this javascript code: $(function(){ var currentCarouselItem = 1; //set carousel to first

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.