kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Sorting algorithms_Quicksort
Go: package main

import "fmt"

func main() {
    list := []int{31, 41, 59, 26, 53, 58, 97, 93, 23, 84}
    fmt.Println("unsorted:", list)

    quicksort(list)
    fmt.Println("sorted!  ", list)
}

func quicksort(a []int) {
    var pex func(int, int)
    pex = func(lower, upper int) {
        for {
            switch upper - lower {
            case -1, 0: 
                return
            case 1: 
                
                if a[upper] < a[lower] {
                    
                    a[upper], a[lower] = a[lower], a[upper]
                }
                return
            
            
            }

            
            
            
            
            
            
            bx := (upper + lower) / 2
            b := a[bx]  
            lp := lower 
            up := upper 
        outer:
            for {
                
                for lp < upper && !(b < a[lp]) {
                    lp++
                }
                for {
                    if lp > up {
                        
                        break outer
                    }
                    
                    if a[up] < b {
                        break 
                    }
                    up--
                }
                
                a[lp], a[up] = a[up], a[lp]
                lp++
                up--
            }
            
            
            if bx < lp {
                
                if bx < lp-1 {
                    
                    a[bx], a[lp-1] = a[lp-1], b
                }
                up = lp - 2
            } else {
                
                if bx > lp {
                    
                    a[bx], a[lp] = a[lp], b
                }
                up = lp - 1
                lp++
            }
            
            
            if up-lower < upper-lp {
                pex(lower, up)
                lower = lp
            } else {
                pex(lp, upper)
                upper = up
            }
        }
    }
    pex(0, len(a)-1)
}

Python: def quickSort(arr):
    less = []
    pivotList = []
    more = []
    if len(arr) <= 1:
        return arr
    else:
        pivot = arr[0]
        for i in arr:
            if i < pivot:
                less.append(i)
            elif i > pivot:
                more.append(i)
            else:
                pivotList.append(i)
        less = quickSort(less)
        more = quickSort(more)
        return less + pivotList + more

a = [4, 65, 2, -31, 0, 99, 83, 782, 1]
a = quickSort(a)
Task: Sorting algorithms_Quicksort
Python: def quickSort(arr):
    less = []
    pivotList = []
    more = []
    if len(arr) <= 1:
        return arr
    else:
        pivot = arr[0]
        for i in arr:
            if i < pivot:
                less.append(i)
            elif i > pivot:
                more.append(i)
            else:
                pivotList.append(i)
        less = quickSort(less)
        more = quickSort(more)
        return less + pivotList + more

a = [4, 65, 2, -31, 0, 99, 83, 782, 1]
a = quickSort(a)

VB: Public Sub Quick(a() As Variant, last As Integer)

Dim aLess() As Variant
Dim aEq() As Variant
Dim aGreater() As Variant
Dim pivot As Variant
Dim naLess As Integer
Dim naEq As Integer
Dim naGreater As Integer

If last > 1 Then
    
    pivot = a(Int((last + 1) / 2))
    
    naLess = 0
    naEq = 0
    naGreater = 0
    For Each el In a()
      If el > pivot Then
        naGreater = naGreater + 1
        ReDim Preserve aGreater(1 To naGreater)
        aGreater(naGreater) = el
      ElseIf el < pivot Then
        naLess = naLess + 1
        ReDim Preserve aLess(1 To naLess)
        aLess(naLess) = el
      Else
        naEq = naEq + 1
        ReDim Preserve aEq(1 To naEq)
        aEq(naEq) = el
      End If
    Next
    
    Quick aLess(), naLess
    Quick aGreater(), naGreater
    
    P = 1
    For i = 1 To naLess
      a(P) = aLess(i): P = P + 1
    Next
    For i = 1 To naEq
      a(P) = aEq(i): P = P + 1
    Next
    For i = 1 To naGreater
      a(P) = aGreater(i): P = P + 1
    Next
End If
End Sub

Public Sub QuicksortTest()
Dim a(1 To 26) As Variant

 
 For i = 1 To 26: a(i) = 26 - i: Next
 Quick a(), 26
 For i = 1 To 26: Debug.Print a(i);: Next
 Debug.Print
 
 For i = 1 To 26: a(i) = Chr$(Asc("z") + 1 - i) & "-stuff": Next
 Quick a(), 26
 For i = 1 To 26: Debug.Print a(i); " ";: Next
 Debug.Print
End Sub
Task: Sorting algorithms_Quicksort
C++: #include <iterator>
#include <algorithm> 
#include <functional> 


template<typename T>
 T median(T t1, T t2, T t3)
{
  if (t1 < t2)
  {
    if (t2 < t3)
      return t2;
    else if (t1 < t3)
      return t3;
    else
      return t1;
  }
  else
  {
    if (t1 < t3)
      return t1;
    else if (t2 < t3)
      return t3;
    else
      return t2;
  }
}


template<typename Order> struct non_strict_op:
  public std::binary_function<typename Order::second_argument_type,
                              typename Order::first_argument_type,
                              bool>
{
  non_strict_op(Order o): order(o) {}
  bool operator()(typename Order::second_argument_type arg1,
                  typename Order::first_argument_type arg2) const
  {
    return !order(arg2, arg1);
  }
private:
  Order order;
};

template<typename Order> non_strict_op<Order> non_strict(Order o)
{
  return non_strict_op<Order>(o);
}

template<typename RandomAccessIterator,
         typename Order>
 void quicksort(RandomAccessIterator first, RandomAccessIterator last, Order order)
{
  if (first != last && first+1 != last)
  {
    typedef typename std::iterator_traits<RandomAccessIterator>::value_type value_type;
    RandomAccessIterator mid = first + (last - first)/2;
    value_type pivot = median(*first, *mid, *(last-1));
    RandomAccessIterator split1 = std::partition(first, last, std::bind2nd(order, pivot));
    RandomAccessIterator split2 = std::partition(split1, last, std::bind2nd(non_strict(order), pivot));
    quicksort(first, split1, order);
    quicksort(split2, last, order);
  }
}

template<typename RandomAccessIterator>
 void quicksort(RandomAccessIterator first, RandomAccessIterator last)
{
  quicksort(first, last, std::less<typename std::iterator_traits<RandomAccessIterator>::value_type>());
}

Java: public static <E extends Comparable<? super E>> List<E> quickSort(List<E> arr) {
    if (arr.isEmpty())
        return arr;
    else {
        E pivot = arr.get(0);

        List<E> less = new LinkedList<E>();
        List<E> pivotList = new LinkedList<E>();
        List<E> more = new LinkedList<E>();

        
        for (E i: arr) {
            if (i.compareTo(pivot) < 0)
                less.add(i);
            else if (i.compareTo(pivot) > 0)
                more.add(i);
            else
                pivotList.add(i);
        }

        
        less = quickSort(less);
        more = quickSort(more);

        
        less.addAll(pivotList);
        less.addAll(more);
        return less;
    }
}
Task: Sorting algorithms_Quicksort
C++: #include <iterator>
#include <algorithm> 
#include <functional> 


template<typename T>
 T median(T t1, T t2, T t3)
{
  if (t1 < t2)
  {
    if (t2 < t3)
      return t2;
    else if (t1 < t3)
      return t3;
    else
      return t1;
  }
  else
  {
    if (t1 < t3)
      return t1;
    else if (t2 < t3)
      return t3;
    else
      return t2;
  }
}


template<typename Order> struct non_strict_op:
  public std::binary_function<typename Order::second_argument_type,
                              typename Order::first_argument_type,
                              bool>
{
  non_strict_op(Order o): order(o) {}
  bool operator()(typename Order::second_argument_type arg1,
                  typename Order::first_argument_type arg2) const
  {
    return !order(arg2, arg1);
  }
private:
  Order order;
};

template<typename Order> non_strict_op<Order> non_strict(Order o)
{
  return non_strict_op<Order>(o);
}

template<typename RandomAccessIterator,
         typename Order>
 void quicksort(RandomAccessIterator first, RandomAccessIterator last, Order order)
{
  if (first != last && first+1 != last)
  {
    typedef typename std::iterator_traits<RandomAccessIterator>::value_type value_type;
    RandomAccessIterator mid = first + (last - first)/2;
    value_type pivot = median(*first, *mid, *(last-1));
    RandomAccessIterator split1 = std::partition(first, last, std::bind2nd(order, pivot));
    RandomAccessIterator split2 = std::partition(split1, last, std::bind2nd(non_strict(order), pivot));
    quicksort(first, split1, order);
    quicksort(split2, last, order);
  }
}

template<typename RandomAccessIterator>
 void quicksort(RandomAccessIterator first, RandomAccessIterator last)
{
  quicksort(first, last, std::less<typename std::iterator_traits<RandomAccessIterator>::value_type>());
}

PHP: function quicksort($arr){
	$lte = $gt = array();
	if(count($arr) < 2){
		return $arr;
	}
	$pivot_key = key($arr);
	$pivot = array_shift($arr);
	foreach($arr as $val){
		if($val <= $pivot){
			$lte[] = $val;
		} else {
			$gt[] = $val;
		}
	}
	return array_merge(quicksort($lte),array($pivot_key=>$pivot),quicksort($gt));
}

$arr = array(1, 3, 5, 7, 9, 8, 6, 4, 2);
$arr = quicksort($arr);
echo implode(',',$arr);
Task: Sorting algorithms_Quicksort
Go: package main

import "fmt"

func main() {
    list := []int{31, 41, 59, 26, 53, 58, 97, 93, 23, 84}
    fmt.Println("unsorted:", list)

    quicksort(list)
    fmt.Println("sorted!  ", list)
}

func quicksort(a []int) {
    var pex func(int, int)
    pex = func(lower, upper int) {
        for {
            switch upper - lower {
            case -1, 0: 
                return
            case 1: 
                
                if a[upper] < a[lower] {
                    
                    a[upper], a[lower] = a[lower], a[upper]
                }
                return
            
            
            }

            
            
            
            
            
            
            bx := (upper + lower) / 2
            b := a[bx]  
            lp := lower 
            up := upper 
        outer:
            for {
                
                for lp < upper && !(b < a[lp]) {
                    lp++
                }
                for {
                    if lp > up {
                        
                        break outer
                    }
                    
                    if a[up] < b {
                        break 
                    }
                    up--
                }
                
                a[lp], a[up] = a[up], a[lp]
                lp++
                up--
            }
            
            
            if bx < lp {
                
                if bx < lp-1 {
                    
                    a[bx], a[lp-1] = a[lp-1], b
                }
                up = lp - 2
            } else {
                
                if bx > lp {
                    
                    a[bx], a[lp] = a[lp], b
                }
                up = lp - 1
                lp++
            }
            
            
            if up-lower < upper-lp {
                pex(lower, up)
                lower = lp
            } else {
                pex(lp, upper)
                upper = up
            }
        }
    }
    pex(0, len(a)-1)
}

PHP: function quicksort($arr){
	$lte = $gt = array();
	if(count($arr) < 2){
		return $arr;
	}
	$pivot_key = key($arr);
	$pivot = array_shift($arr);
	foreach($arr as $val){
		if($val <= $pivot){
			$lte[] = $val;
		} else {
			$gt[] = $val;
		}
	}
	return array_merge(quicksort($lte),array($pivot_key=>$pivot),quicksort($gt));
}

$arr = array(1, 3, 5, 7, 9, 8, 6, 4, 2);
$arr = quicksort($arr);
echo implode(',',$arr);
Task: Sorting algorithms_Quicksort
Java: public static <E extends Comparable<? super E>> List<E> quickSort(List<E> arr) {
    if (arr.isEmpty())
        return arr;
    else {
        E pivot = arr.get(0);

        List<E> less = new LinkedList<E>();
        List<E> pivotList = new LinkedList<E>();
        List<E> more = new LinkedList<E>();

        
        for (E i: arr) {
            if (i.compareTo(pivot) < 0)
                less.add(i);
            else if (i.compareTo(pivot) > 0)
                more.add(i);
            else
                pivotList.add(i);
        }

        
        less = quickSort(less);
        more = quickSort(more);

        
        less.addAll(pivotList);
        less.addAll(more);
        return less;
    }
}

PHP: function quicksort($arr){
	$lte = $gt = array();
	if(count($arr) < 2){
		return $arr;
	}
	$pivot_key = key($arr);
	$pivot = array_shift($arr);
	foreach($arr as $val){
		if($val <= $pivot){
			$lte[] = $val;
		} else {
			$gt[] = $val;
		}
	}
	return array_merge(quicksort($lte),array($pivot_key=>$pivot),quicksort($gt));
}

$arr = array(1, 3, 5, 7, 9, 8, 6, 4, 2);
$arr = quicksort($arr);
echo implode(',',$arr);
Task: Sorting algorithms_Quicksort
Python: def quickSort(arr):
    less = []
    pivotList = []
    more = []
    if len(arr) <= 1:
        return arr
    else:
        pivot = arr[0]
        for i in arr:
            if i < pivot:
                less.append(i)
            elif i > pivot:
                more.append(i)
            else:
                pivotList.append(i)
        less = quickSort(less)
        more = quickSort(more)
        return less + pivotList + more

a = [4, 65, 2, -31, 0, 99, 83, 782, 1]
a = quickSort(a)

PHP: function quicksort($arr){
	$lte = $gt = array();
	if(count($arr) < 2){
		return $arr;
	}
	$pivot_key = key($arr);
	$pivot = array_shift($arr);
	foreach($arr as $val){
		if($val <= $pivot){
			$lte[] = $val;
		} else {
			$gt[] = $val;
		}
	}
	return array_merge(quicksort($lte),array($pivot_key=>$pivot),quicksort($gt));
}

$arr = array(1, 3, 5, 7, 9, 8, 6, 4, 2);
$arr = quicksort($arr);
echo implode(',',$arr);
Task: Sorting algorithms_Quicksort
VB: Public Sub Quick(a() As Variant, last As Integer)

Dim aLess() As Variant
Dim aEq() As Variant
Dim aGreater() As Variant
Dim pivot As Variant
Dim naLess As Integer
Dim naEq As Integer
Dim naGreater As Integer

If last > 1 Then
    
    pivot = a(Int((last + 1) / 2))
    
    naLess = 0
    naEq = 0
    naGreater = 0
    For Each el In a()
      If el > pivot Then
        naGreater = naGreater + 1
        ReDim Preserve aGreater(1 To naGreater)
        aGreater(naGreater) = el
      ElseIf el < pivot Then
        naLess = naLess + 1
        ReDim Preserve aLess(1 To naLess)
        aLess(naLess) = el
      Else
        naEq = naEq + 1
        ReDim Preserve aEq(1 To naEq)
        aEq(naEq) = el
      End If
    Next
    
    Quick aLess(), naLess
    Quick aGreater(), naGreater
    
    P = 1
    For i = 1 To naLess
      a(P) = aLess(i): P = P + 1
    Next
    For i = 1 To naEq
      a(P) = aEq(i): P = P + 1
    Next
    For i = 1 To naGreater
      a(P) = aGreater(i): P = P + 1
    Next
End If
End Sub

Public Sub QuicksortTest()
Dim a(1 To 26) As Variant

 
 For i = 1 To 26: a(i) = 26 - i: Next
 Quick a(), 26
 For i = 1 To 26: Debug.Print a(i);: Next
 Debug.Print
 
 For i = 1 To 26: a(i) = Chr$(Asc("z") + 1 - i) & "-stuff": Next
 Quick a(), 26
 For i = 1 To 26: Debug.Print a(i); " ";: Next
 Debug.Print
End Sub

PHP: function quicksort($arr){
	$lte = $gt = array();
	if(count($arr) < 2){
		return $arr;
	}
	$pivot_key = key($arr);
	$pivot = array_shift($arr);
	foreach($arr as $val){
		if($val <= $pivot){
			$lte[] = $val;
		} else {
			$gt[] = $val;
		}
	}
	return array_merge(quicksort($lte),array($pivot_key=>$pivot),quicksort($gt));
}

$arr = array(1, 3, 5, 7, 9, 8, 6, 4, 2);
$arr = quicksort($arr);
echo implode(',',$arr);
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

C#: string s = "Hello, world!";
int characterLength = s.Length;
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}
Task: String length
C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}

Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}
Task: String length
C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}

Java: String s = "Hello, world!"; 
int byteCountUTF16 = s.getBytes("UTF-16").length; 
int byteCountUTF16LE = s.getBytes("UTF-16LE").length; 
int byteCountUTF8  = s.getBytes("UTF-8").length;
Task: String length
C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}

Python: print len('ascii')
Task: String length
C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}

VB: Module ByteLength
    Function GetByteLength(s As String, encoding As Text.Encoding) As Integer
        Return encoding.GetByteCount(s)
    End Function
End Module
Task: String length
C#: string s = "Hello, world!";
int characterLength = s.Length;

Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}
Task: String length
C#: string s = "Hello, world!";
int characterLength = s.Length;

Java: String s = "Hello, world!"; 
int byteCountUTF16 = s.getBytes("UTF-16").length; 
int byteCountUTF16LE = s.getBytes("UTF-16LE").length; 
int byteCountUTF8  = s.getBytes("UTF-8").length;
Task: String length
C#: string s = "Hello, world!";
int characterLength = s.Length;

VB: Module ByteLength
    Function GetByteLength(s As String, encoding As Text.Encoding) As Integer
        Return encoding.GetByteCount(s)
    End Function
End Module
Task: String length
Java: String s = "Hello, world!"; 
int byteCountUTF16 = s.getBytes("UTF-16").length; 
int byteCountUTF16LE = s.getBytes("UTF-16LE").length; 
int byteCountUTF8  = s.getBytes("UTF-8").length; 

Python: print len('ascii')
Task: String length
Java: String s = "Hello, world!"; 
int byteCountUTF16 = s.getBytes("UTF-16").length; 
int byteCountUTF16LE = s.getBytes("UTF-16LE").length; 
int byteCountUTF8  = s.getBytes("UTF-8").length; 

VB: Module ByteLength
    Function GetByteLength(s As String, encoding As Text.Encoding) As Integer
        Return encoding.GetByteCount(s)
    End Function
End Module
Task: String length
Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}

Python: print len('ascii')
Task: String length
Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}

VB: Module ByteLength
    Function GetByteLength(s As String, encoding As Text.Encoding) As Integer
        Return encoding.GetByteCount(s)
    End Function
End Module
Task: String length
Python: print len('ascii')


VB: Module ByteLength
    Function GetByteLength(s As String, encoding As Text.Encoding) As Integer
        Return encoding.GetByteCount(s)
    End Function
End Module
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

Java: String s = "Hello, world!"; 
int byteCountUTF16 = s.getBytes("UTF-16").length; 
int byteCountUTF16LE = s.getBytes("UTF-16LE").length; 
int byteCountUTF8  = s.getBytes("UTF-8").length;
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

VB: Module ByteLength
    Function GetByteLength(s As String, encoding As Text.Encoding) As Integer
        Return encoding.GetByteCount(s)
    End Function
End Module
Task: String length
Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}

Java: String s = "Hello, world!"; 
int byteCountUTF16 = s.getBytes("UTF-16").length; 
int byteCountUTF16LE = s.getBytes("UTF-16LE").length; 
int byteCountUTF8  = s.getBytes("UTF-8").length;
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

Python: print len('ascii')
Task: String length
C#: string s = "Hello, world!";
int characterLength = s.Length;

C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}
Task: String length
C: #include <string.h>

int main(void) 
{
  const char *string = "Hello, world!";
  size_t length = strlen(string);
         
  return 0;
}

PHP: <?php
foreach (array('møøse', '𝔘𝔫𝔦𝔠𝔬𝔡𝔢', 'J̲o̲s̲é̲') as $s1) { 
   printf('String "%s" measured with strlen: %d mb_strlen: %s grapheme_strlen %s%s', 
                  $s1, strlen($s1),mb_strlen($s1), grapheme_strlen($s1), PHP_EOL);
}
Task: String length
C#: string s = "Hello, world!";
int characterLength = s.Length;

PHP: <?php
foreach (array('møøse', '𝔘𝔫𝔦𝔠𝔬𝔡𝔢', 'J̲o̲s̲é̲') as $s1) { 
   printf('String "%s" measured with strlen: %d mb_strlen: %s grapheme_strlen %s%s', 
                  $s1, strlen($s1),mb_strlen($s1), grapheme_strlen($s1), PHP_EOL);
}
Task: String length
C++: #include <string> 
using std::string;

int main()
{
  string s = "Hello, world!";
  string::size_type length = s.length(); 
  string::size_type size = s.size();     
  
  string::size_type bytes = s.length() * sizeof(string::value_type); 
}

PHP: <?php
foreach (array('møøse', '𝔘𝔫𝔦𝔠𝔬𝔡𝔢', 'J̲o̲s̲é̲') as $s1) { 
   printf('String "%s" measured with strlen: %d mb_strlen: %s grapheme_strlen %s%s', 
                  $s1, strlen($s1),mb_strlen($s1), grapheme_strlen($s1), PHP_EOL);
}
Task: String length
Go: package main

import "fmt"

func main() {
    m := "møøse"
    u := "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
    j := "J̲o̲s̲é̲"
    fmt.Printf("%d %s % x\n", len(m), m, m)
    fmt.Printf("%d %s % x\n", len(u), u, u)
    fmt.Printf("%d %s % x\n", len(j), j, j)
}

PHP: <?php
foreach (array('møøse', '𝔘𝔫𝔦𝔠𝔬𝔡𝔢', 'J̲o̲s̲é̲') as $s1) { 
   printf('String "%s" measured with strlen: %d mb_strlen: %s grapheme_strlen %s%s', 
                  $s1, strlen($s1),mb_strlen($s1), grapheme_strlen($s1), PHP_EOL);
}