WeixiangYan/CodeTransOcean huggingface dataset:
Task: Call an object method

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
        int x;
        int (*funcPtr)(int);
}functionPair;

int factorial(int num){
        if(num==0||num==1)
                return 1;
        else
                return num*factorial(num-1);
}

int main(int argc,char** argv)
{
        functionPair response;

        if(argc!=2)
                return printf("Usage : %s <non negative integer>",argv[0]);
        else{
                response = (functionPair){.x = atoi(argv[1]),.funcPtr=&factorial};
                printf("\nFactorial of %d is %d\n",response.x,response.funcPtr(response.x));
        }
        return 0;
}








VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);


C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);



Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);




Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);







VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);


Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);



Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);





Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);




VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)




Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)
Task: Call an object method







Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)


VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);






VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)


Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);






Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);



Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)





VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Call an object method

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
        int x;
        int (*funcPtr)(int);
}functionPair;

int factorial(int num){
        if(num==0||num==1)
                return 1;
        else
                return num*factorial(num-1);
}

int main(int argc,char** argv)
{
        functionPair response;

        if(argc!=2)
                return printf("Usage : %s <non negative integer>",argv[0]);
        else{
                response = (functionPair){.x = atoi(argv[1]),.funcPtr=&factorial};
                printf("\nFactorial of %d is %d\n",response.x,response.funcPtr(response.x));
        }
        return 0;
}






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);
Task: Call an object method



C#: 
MyClass.Method(someParameter);
 

myInstance.Method(someParameter);




PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);
Task: Call an object method


C++: 
MyClass::method(someParameter);


myInstance.method(someParameter);


MyPointer->method(someParameter);





PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);
Task: Call an object method




Go: type Foo int 


func (self Foo) ValueMethod(x int) { }


func (self *Foo) PointerMethod(x int) { }


var myValue Foo
var myPointer *Foo = new(Foo)


myValue.ValueMethod(someParameter)

myPointer.PointerMethod(someParameter)



myPointer.ValueMethod(someParameter)



myValue.PointerMethod(someParameter)


Foo.ValueMethod(myValue, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)



PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);
Task: Call an object method





Java: 
MyClass.method(someParameter);


myInstance.method(someParameter);


PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);
Task: Call an object method






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);


Python: class MyClass(object):
	@classmethod
	def myClassMethod(self, x):
		pass
	@staticmethod
	def myStaticMethod(x):
		pass
	def myMethod(self, x):
		return 42 + x

myInstance = MyClass()


myInstance.myMethod(someParameter)

MyClass.myMethod(myInstance, someParameter)



MyClass.myClassMethod(someParameter)
MyClass.myStaticMethod(someParameter)

myInstance.myClassMethod(someParameter)
myInstance.myStaticMethod(someParameter)
Task: Call an object method






PHP: 
MyClass::method($someParameter);

$foo = 'MyClass';
$foo::method($someParameter);

$myInstance->method($someParameter);



VB: Option Explicit

Sub Method_1(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub

Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
    If myStr <> "" Then strTemp = myStr
    Debug.Print strTemp
End Sub
Task: Mosaic matrix

C: #include <stdio.h>

void mosaicMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if ((i + j) % 2 == 0) {
                printf("%s ", "1");
            } else {
                printf("%s ", "0");
            }
        }
        printf("\n");
    }
}

int main() {
    mosaicMatrix(10);
    printf("\n");
    mosaicMatrix(11);
    return 0;
}



C#: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto mosaic = [](int x, int y, [[maybe_unused]]int size)
  {
    return (x + y) % 2 == 0;
  };

  PrintMatrix(mosaic, 8);
  PrintMatrix(mosaic, 9);
}
Task: Mosaic matrix

C: #include <stdio.h>

void mosaicMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if ((i + j) % 2 == 0) {
                printf("%s ", "1");
            } else {
                printf("%s ", "0");
            }
        }
        printf("\n");
    }
}

int main() {
    mosaicMatrix(10);
    printf("\n");
    mosaicMatrix(11);
    return 0;
}




Go: package main

import "fmt"

func mosaicMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if (i+j)%2 == 0 {
                fmt.Printf("%s ", "1")
            } else {
                fmt.Printf("%s ", ".")
            }
        }
        fmt.Println()
    }
}

func main() {
    mosaicMatrix(7)
    fmt.Println()
    mosaicMatrix(8)
}
Task: Mosaic matrix

C: #include <stdio.h>

void mosaicMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if ((i + j) % 2 == 0) {
                printf("%s ", "1");
            } else {
                printf("%s ", "0");
            }
        }
        printf("\n");
    }
}

int main() {
    mosaicMatrix(10);
    printf("\n");
    mosaicMatrix(11);
    return 0;
}







Python: size = 9
for Row in range(size):
    for Col in range(size):
        if (Row % 2 == 1 and Col % 2 == 1) or (Row % 2 == 0 and Col % 2 == 0):
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Mosaic matrix


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto mosaic = [](int x, int y, [[maybe_unused]]int size)
  {
    return (x + y) % 2 == 0;
  };

  PrintMatrix(mosaic, 8);
  PrintMatrix(mosaic, 9);
}



Go: package main

import "fmt"

func mosaicMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if (i+j)%2 == 0 {
                fmt.Printf("%s ", "1")
            } else {
                fmt.Printf("%s ", ".")
            }
        }
        fmt.Println()
    }
}

func main() {
    mosaicMatrix(7)
    fmt.Println()
    mosaicMatrix(8)
}
Task: Mosaic matrix


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto mosaic = [](int x, int y, [[maybe_unused]]int size)
  {
    return (x + y) % 2 == 0;
  };

  PrintMatrix(mosaic, 8);
  PrintMatrix(mosaic, 9);
}






Python: size = 9
for Row in range(size):
    for Col in range(size):
        if (Row % 2 == 1 and Col % 2 == 1) or (Row % 2 == 0 and Col % 2 == 0):
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Mosaic matrix




Go: package main

import "fmt"

func mosaicMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if (i+j)%2 == 0 {
                fmt.Printf("%s ", "1")
            } else {
                fmt.Printf("%s ", ".")
            }
        }
        fmt.Println()
    }
}

func main() {
    mosaicMatrix(7)
    fmt.Println()
    mosaicMatrix(8)
}


Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if((i+j)%2==0){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}
Task: Mosaic matrix





Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if((i+j)%2==0){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}



Python: size = 9
for Row in range(size):
    for Col in range(size):
        if (Row % 2 == 1 and Col % 2 == 1) or (Row % 2 == 0 and Col % 2 == 0):
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Mosaic matrix




Go: package main

import "fmt"

func mosaicMatrix(n uint) {
    for i := uint(0); i < n; i++ {
        for j := uint(0); j < n; j++ {
            if (i+j)%2 == 0 {
                fmt.Printf("%s ", "1")
            } else {
                fmt.Printf("%s ", ".")
            }
        }
        fmt.Println()
    }
}

func main() {
    mosaicMatrix(7)
    fmt.Println()
    mosaicMatrix(8)
}




Python: size = 9
for Row in range(size):
    for Col in range(size):
        if (Row % 2 == 1 and Col % 2 == 1) or (Row % 2 == 0 and Col % 2 == 0):
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()
Task: Mosaic matrix

C: #include <stdio.h>

void mosaicMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if ((i + j) % 2 == 0) {
                printf("%s ", "1");
            } else {
                printf("%s ", "0");
            }
        }
        printf("\n");
    }
}

int main() {
    mosaicMatrix(10);
    printf("\n");
    mosaicMatrix(11);
    return 0;
}


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto mosaic = [](int x, int y, [[maybe_unused]]int size)
  {
    return (x + y) % 2 == 0;
  };

  PrintMatrix(mosaic, 8);
  PrintMatrix(mosaic, 9);
}
Task: Mosaic matrix


C++: #include <concepts>
#include <iostream>



void PrintMatrix(std::predicate<int, int, int> auto f, int size)
{
  for(int y = 0; y < size; y++)
  {
    for(int x = 0; x < size; x++)
    {
      std::cout << " " << f(x, y, size);
    }
    std::cout << "\n";
  }
  std::cout << "\n";
}

int main()
{
  
  auto mosaic = [](int x, int y, [[maybe_unused]]int size)
  {
    return (x + y) % 2 == 0;
  };

  PrintMatrix(mosaic, 8);
  PrintMatrix(mosaic, 9);
}




Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if((i+j)%2==0){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}
Task: Mosaic matrix

C: #include <stdio.h>

void mosaicMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if ((i + j) % 2 == 0) {
                printf("%s ", "1");
            } else {
                printf("%s ", "0");
            }
        }
        printf("\n");
    }
}

int main() {
    mosaicMatrix(10);
    printf("\n");
    mosaicMatrix(11);
    return 0;
}





Java: 

size(1000,1000);

textSize(50);

for(int i=0;i<10;i++){
  for(int j=0;j<10;j++){
    noFill();
    square(i*100,j*100,100);
    fill(#000000);
    if((i+j)%2==0){
      text("1",i*100+50,j*100+50);
    }
    else{
      text("0",i*100+50,j*100+50);
    } 
  }
}
Task: Strip control codes and extended characters from a string

C: #include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define MAXBUF 256  
#define STR_SZ 100   



int ascii (const unsigned char c);

int ascii_ext (const unsigned char c);

unsigned char* strip(unsigned char* str, const size_t n, int ext );


 
int ascii (const unsigned char c) 
{  
  unsigned char min = 32;   
  unsigned char max = 126;  

  if ( c>=min && c<=max ) return 1;

  return 0;
} 


 
int ascii_ext (const unsigned char c) 
{  
  unsigned char min_ext = 128;   
  unsigned char max_ext = 255;

  if ( c>=min_ext && c<=max_ext )
       return 1;

  return 0;
} 




unsigned char* strip( unsigned char* str, const size_t n, int ext) 
{ 

  unsigned char buffer[MAXBUF] = {'\0'};

  size_t i = 0;  
  size_t j = 0;  

  size_t max = (n<MAXBUF)? n : MAXBUF -1;  

  while (i < max )
    {
      if ( (ext && ascii_ext(str[i]) ) ||  (ascii(str[i]) ) )    
	{
	  buffer[j++] = str[i]; 
	}      
      i++;
    }

  memset(str, '\0', max); 

  i = 0;               

  while( i < j)
    {
      str[i] = buffer[i]; 
      i++;
    }

  str[j] = '\0';  

  return str;  
}


int main( int argc, char** argv)
{
  enum {ASCII=0, EXT=1}; 

  unsigned int seed = 134529;  

  
  unsigned char badstring[STR_SZ] = {'\0'};
  unsigned char bs_2[STR_SZ]      = {'\0'};
 
  unsigned char* goodstring = NULL;
  unsigned char* goodstring_ext = NULL;

  size_t i = 0;

  srand(seed); 

  fprintf(stdout, "Original:\t" );

  
  for (i = 0; i < STR_SZ; i++)
    {
      badstring[i] = (unsigned char) ( rand () & (unsigned char)0xFF );
      fprintf(stdout, "%c", badstring[i] );
    }
  fprintf(stdout, "\n");

   
   memcpy(bs_2, badstring, STR_SZ * sizeof(unsigned char) ); 

   goodstring_ext = strip( badstring, STR_SZ, EXT); 

   fprintf(stdout, "\nEXT:\t%s\n" , goodstring_ext );

   goodstring = strip( bs_2, STR_SZ, ASCII); 
  
   fprintf(stdout, "\nASCII:\t%s\n" , goodstring );
  
return 0;
}





Java: import java.util.function.IntPredicate;

public class StripControlCodes {

    public static void main(String[] args) {
        String s = "\u0000\n abc\u00E9def\u007F";
        System.out.println(stripChars(s, c -> c > '\u001F' && c != '\u007F'));
        System.out.println(stripChars(s, c -> c > '\u001F' && c < '\u007F'));
    }

    static String stripChars(String s, IntPredicate include) {
        return s.codePoints().filter(include::test).collect(StringBuilder::new,
                StringBuilder::appendCodePoint, StringBuilder::append).toString();
    }
}