File: unicode2sms

package info (click to toggle)
smstools 3.1.15-1.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,656 kB
  • ctags: 879
  • sloc: ansic: 14,857; sh: 1,195; php: 115; makefile: 48; awk: 17
file content (36 lines) | stat: -rwxr-xr-x 754 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash

# This script converts a pure unicode text file into an sms file for sending.

if [ $# -ne 1 ]; then
  echo "Usage: unicode2sms filename"
  exit 1
fi

if grep ".A.l.p.h.a.b.e.t.:.*U.C.S" $1 >/dev/null; then
  ucs2=true
else
  ucs2=false
fi

text=`od -t x1 $1 | cut -c8-99`
foundstart="false"
position="first"
for character in $text; do
  if [ "$position" = "first" ]; then
    if [ "$foundstart" = "true" ]; then
      echo -en "\x$character"
    fi
    position="second"
  else
    if [ "$character" != "ff" ]; then
      echo -en "\x$character"
    fi  
    if [ "$foundstart" = "false" ] && [ "$character" = "0a" ] && [ "$previous" = "0a" ]; then
      foundstart="true"
    fi
    previous="$character"
    position="first"
  fi  
done