1132718Skan/* 290075Sobrien * Copyright (C) 1999-2000 Free Software Foundation, Inc. 3169689Skan * This file is part of the GNU LIBICONV Library. 490075Sobrien * 5169689Skan * The GNU LIBICONV Library is free software; you can redistribute it 690075Sobrien * and/or modify it under the terms of the GNU Library General Public 7132718Skan * License as published by the Free Software Foundation; either version 2 890075Sobrien * of the License, or (at your option) any later version. 990075Sobrien * 1090075Sobrien * The GNU LIBICONV Library is distributed in the hope that it will be 1190075Sobrien * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 1290075Sobrien * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1390075Sobrien * Library General Public License for more details. 1490075Sobrien * 1590075Sobrien * You should have received a copy of the GNU Library General Public 1690075Sobrien * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 1790075Sobrien * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, 1890075Sobrien * Fifth Floor, Boston, MA 02110-1301, USA. 1990075Sobrien */ 2090075Sobrien 21169689Skan/* 22169689Skan * UCS-4BE = UCS-4 big endian 2390075Sobrien */ 2490075Sobrien 25132718Skanstatic int 26132718Skanucs4be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) 27132718Skan{ 2890075Sobrien if (n >= 4) { 2990075Sobrien *pwc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; 3090075Sobrien return 4; 31169689Skan } 3290075Sobrien return RET_TOOFEW(0); 3390075Sobrien} 3490075Sobrien 3590075Sobrienstatic int 3690075Sobrienucs4be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 3790075Sobrien{ 38117395Skan if (n >= 4) { 39132718Skan r[0] = (unsigned char) (wc >> 24); 4090075Sobrien r[1] = (unsigned char) (wc >> 16); 4190075Sobrien r[2] = (unsigned char) (wc >> 8); 4290075Sobrien r[3] = (unsigned char) wc; 4390075Sobrien return 4; 4490075Sobrien } else 4590075Sobrien return RET_TOOSMALL; 4690075Sobrien} 4790075Sobrien