Use Special Characters in Windows Phone 8 Application

Before few days, I was working on a Windows Phone Application Development and one of its feature demanded me to use special characters in the app. As this feature is not available directly so there was big question in my mind how to use it ?

But after lot of research and working on it, I got the trick to use special characters in Windows Phone 8 app development ( can also be used in Windows Phone 7 apps ) and would like to share with you all in below tutorial.

XAML is an XML file format so XAML codes should follow all XML rules. Here, I am assuming that you are already aware about those rules.

There is a XML rule that can create a problem when using strings within attributes in XAML. Here, my concern is using special characters in XAML due to the reason that XML reserves some special characters for its own specification and format. For example, the less than sign <>, brackets (), ampersand (&), apostrophe (‘) and double quote (“) are used as XML formatting elements within an XML file. So when you will use these reserved characters within a Text property or Content property (in XAML code), you will need to use the XML escape characters.

————————————

Adding some extended characters (that are not on your keyboard) can be easily done in XAML.

1

2

3

4

5

6

7

8

<StackPanel>

<TextBlock Name="txt1"FontSize="50"Text="&lt; good moring &gt;"/>

<TextBlock Name="txt2"FontSize="50"Text="Pound : [&]#163;"/>

<TextBlock Name="txt3"FontSize="50"Text="Yen : [&]#165;"/>

<TextBlock Name="txt4"FontSize="50"Text="No : [&]#x1f6ab;"/>

<TextBlock Name="txt5"FontSize="50"Text="Taxi : [&]#x1f695;"/>

<TextBlock Name="txt6"FontSize="50"Text="Sunrise : [&]#x1f304; "/>

</StackPanel>

You can also specify special characters dynamically in code behind page. But here you need to remember one thing (XML rule) instead of writing & #x1f304;, you could write \u1f304; instead.

C#

1

2

txt5.Text="Taxi : \u1f695";

txt6.Text="Sunrise : \u1f304";

Following are some entities’ unicode.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

[&]#x1f4ce; PAPERCLIP

[&]#x1f354; HAMBURGER

[&]#x2712; BLACK NIB

[&]#x1f34f; GREEN APPLE

[&]#x1f52d; TELESCOPE

[&]#x1f34d; PINEAPPLE

[&]#x1f3bb; VIOLIN

[&]#x1f3e0; HOUSE BUILDING

[&]#x26bd; SOCCER BALL

[&]#x1f3e5; HOSPITAL

[&]#x1f6b4; BICYCLIST

[&]#x1f5fd; STATUE OF LIBERTY

[&]#x1f37a; BEER MUG

[&]#x1f6a2; SHIP

Note : You must remove “[” and “]” before and after “&” sign to use.

Windows Phone 7

Windows Phone 8

So this was it on using special characters in Windows phone 8 app. Drop your queries or comments if any.