Seluj78/Minishell

View on GitHub
libft/ft_charwlen.c

Summary

Maintainability
Test Coverage
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_charwlen.c                                      :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: estephan <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2016/11/30 13:57:51 by estephan          #+#    #+#             */
/*   Updated: 2016/11/30 13:58:17 by estephan         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft.h"

int        ft_charwlen(int c)
{
    if (c <= 0x7F)
        return (1);
    if (c <= 0x7FF)
        return (2);
    if (c <= 0xFFFF)
        return (3);
    if (c <= 0x10FFFF)
        return (4);
    return (0);
}