|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 my $utils_PL_Included = 1; |
|
18 |
|
19 #------------------------------------------------------------------------------------ |
|
20 # GetPathFileName |
|
21 # |
|
22 # Parameters: |
|
23 # $str |
|
24 #------------------------------------------------------------------------------------ |
|
25 sub GetPathFileName |
|
26 { |
|
27 my ($str) = @_; |
|
28 |
|
29 my $startPos = rindex($str, "\\"); |
|
30 if($startPos == -1) |
|
31 { |
|
32 $startPos = rindex($str, "/"); |
|
33 return $str if($startPos == -1); |
|
34 } |
|
35 |
|
36 my $filename = substr($str, $startPos+1); |
|
37 |
|
38 return $filename; |
|
39 } |
|
40 |
|
41 #------------------------------------------------------------------------------------ |
|
42 # GetPathDir |
|
43 # |
|
44 # Parameters: |
|
45 # $str |
|
46 #------------------------------------------------------------------------------------ |
|
47 sub GetPathDir |
|
48 { |
|
49 my ($str) = @_; |
|
50 |
|
51 my $startPos = rindex($str, "\\"); |
|
52 if($startPos == -1) |
|
53 { |
|
54 $startPos = rindex($str, "/"); |
|
55 return $str if($startPos == -1); |
|
56 } |
|
57 |
|
58 my $filename = substr($str, 0, $startPos+1); |
|
59 |
|
60 return $filename; |
|
61 } |
|
62 |
|
63 #------------------------------------------------------------------------------------ |
|
64 # RemoveWhiteSpaces |
|
65 # |
|
66 # Parameters: |
|
67 # $text |
|
68 #------------------------------------------------------------------------------------ |
|
69 sub RemoveWhiteSpaces |
|
70 { |
|
71 my ($text) = @_; |
|
72 ${$text} =~ s/\s+$//; #whitespaces in the end |
|
73 ${$text} =~ s/^\s+//; #whitespaces at the start |
|
74 } |
|
75 |
|
76 #------------------------------------------------------------------------------------ |
|
77 # XmlReadyText |
|
78 # |
|
79 # Parameters: |
|
80 # $text |
|
81 #------------------------------------------------------------------------------------ |
|
82 sub XmlReadyText |
|
83 { |
|
84 my ($text) = @_; |
|
85 |
|
86 my $txtlt = "<"; |
|
87 my $txtgt = ">"; |
|
88 ${$text} =~ s/</$txtlt/g; |
|
89 ${$text} =~ s/>/$txtgt/g; |
|
90 |
|
91 ${$text} =~ s/Ä/Ä/g; |
|
92 ${$text} =~ s/ä/ä/g; |
|
93 ${$text} =~ s/Ö/Ö/g; |
|
94 ${$text} =~ s/ö/ö/g; |
|
95 } |
|
96 |
|
97 #------------------------------------------------------------------------------------ |
|
98 # XmlToText |
|
99 # |
|
100 # Parameters: |
|
101 # $text |
|
102 #------------------------------------------------------------------------------------ |
|
103 sub XmlToText |
|
104 { |
|
105 my ($text) = @_; |
|
106 |
|
107 $txtlt = "<"; |
|
108 $txtgt = ">"; |
|
109 ${$text} =~ s/$txtlt/</g; |
|
110 ${$text} =~ s/$txtgt/>/g; |
|
111 |
|
112 ${$text} =~ s/Ä/Ä/g; |
|
113 ${$text} =~ s/ä/ä/g; |
|
114 ${$text} =~ s/Ö/Ö/g; |
|
115 ${$text} =~ s/ö/ö/g; |
|
116 } |