Using tr ard wc:
function countchar()
{
while IFS= read -r i; do echoprintf "%s" "$i" | tr -dc "$1" | wc -c;m; done
}
Usage:
$ countchar '"' <file.txt #returns one count per line of file.txt
1
3
0
$ countchar ')' #will count parenthesis from stdin
$ countchar '0123456789' #will count numbers from stdin